|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.terminal.gwt.client.ApplicationConnection
public class ApplicationConnection
This is the client side communication "engine", managing client-server
communication with its server side counterpart
AbstractCommunicationManager
.
Client-side widgets receive updates from the corresponding server-side
components as calls to
Paintable.updateFromUIDL(UIDL, ApplicationConnection)
(not to be
confused with the server side interface Paintable
). Any client-side changes (typically resulting from user actions) are sent
back to the server as variable changes (see #updateVariable()
).
TODO document better
Entry point classes (widgetsets) define onModuleLoad()
.
Field Summary | |
---|---|
protected boolean |
applicationRunning
|
static String |
ATTRIBUTE_DESCRIPTION
|
static String |
ATTRIBUTE_ERROR
|
static String |
DISABLED_CLASSNAME
|
static String |
GENERATED_BODY_CLASSNAME
|
protected int |
lastProcessingTime
Holds the time spent rendering the last request |
static String |
PARAM_UNLOADBURST
|
protected int |
totalProcessingTime
Holds the total time spent rendering requests during the lifetime of the session. |
static String |
UIDL_REFRESH_TOKEN
A string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page. |
static String |
UIDL_SECURITY_HEADER
Deprecated. use UIDL_SECURITY_TOKEN_ID instead |
static String |
UIDL_SECURITY_TOKEN_ID
|
static char |
VAR_ARRAYITEM_SEPARATOR
|
static char |
VAR_BURST_SEPARATOR
|
static char |
VAR_ESCAPE_CHARACTER
|
static char |
VAR_FIELD_SEPARATOR
|
static char |
VAR_RECORD_SEPARATOR
|
Constructor Summary | |
---|---|
ApplicationConnection()
|
Method Summary | |
---|---|
static String |
addGetParameters(String uri,
String extraParams)
Adds the get parameters to the uri and returns the new uri that contains the parameters. |
void |
addPngFix(com.google.gwt.user.client.Element el)
Adds PNG-fix conditionally (only for IE6) to the specified IMG -element. |
void |
analyzeLayouts()
Requests an analyze of layouts, to find inconsistencies. |
void |
captionSizeUpdated(Paintable component)
Use to notify that the given component's caption has changed; layouts may have to be recalculated. |
protected void |
doAsyncUIDLRequest(String uri,
String payload,
com.google.gwt.http.client.RequestCallback requestCallback)
Sends an asynchronous UIDL request to the server using the given URI. |
protected void |
doUidlRequest(String uri,
String payload,
boolean synchronous)
Sends an asynchronous or synchronous UIDL request to the server using the given URI. |
protected void |
endRequest()
|
protected String |
escapeVariableValue(String value)
Encode burst, record, field and array item separator characters in a String for transport over the network. |
protected void |
extendLiferaySession()
If on Liferay and logged in, ask the client side session management JavaScript to extend the session duration. |
void |
forceLayout()
This will cause re-layouting of all components. |
String |
getAppUri()
Gets the application base URI. |
ApplicationConfiguration |
getConfiguration()
Gets the ApplicationConfiguration for the current application. |
static Console |
getConsole()
Deprecated. Developers should use VConsole since 6.4.5 |
VContextMenu |
getContextMenu()
Singleton method to get instance of app's context menu. |
com.google.gwt.user.client.Element |
getElementByPid(String pid)
Gets the main element for the paintable with the given id. |
Paintable |
getPaintable(com.google.gwt.user.client.Element element)
Returns a Paintable element by its root element |
Paintable |
getPaintable(String id)
Returns Paintable element by its id |
Paintable |
getPaintable(UIDL uidl)
Get either existing or new Paintable for given UIDL. |
String |
getPid(com.google.gwt.user.client.Element el)
Gets the paintableId using a DOM element - the element should be the main element for a paintable otherwise no id will be found. |
String |
getPid(Paintable paintable)
Gets the paintableId for a specific paintable (a.k.a Vaadin Widget). |
RenderInformation.FloatSize |
getRelativeSize(com.google.gwt.user.client.ui.Widget widget)
Gets the specified Paintables relative size (percent). |
String |
getResource(String name)
Gets a recource that has been pre-loaded via UIDL, such as custom layouts. |
static String |
getStyleName(String primaryStyleName,
UIDL uidl,
boolean field)
Generates the style name for the widget based on the given primary style name (typically returned by Widget.getPrimaryStyleName()) and the UIDL. |
String |
getThemeUri()
Gets the URI for the current theme. |
TooltipInfo |
getTooltipTitleInfo(Paintable titleOwner,
Object key)
Data showed in tooltips are stored centrilized as it may be needed in varios place: caption, layouts, and in owner components themselves. |
protected String |
getUidlSecurityKey()
|
VView |
getView()
Gets the main view, a.k.a top-level window. |
protected String |
getWindowName()
|
boolean |
handleComponentRelativeSize(com.google.gwt.user.client.ui.Widget child)
Converts relative sizes into pixel sizes. |
void |
handleTooltipEvent(com.google.gwt.user.client.Event event,
Paintable owner)
Component may want to delegate Tooltip handling to client. |
void |
handleTooltipEvent(com.google.gwt.user.client.Event event,
Paintable owner,
Object key)
Component may want to delegate Tooltip handling to client. |
protected void |
handleUIDLMessage(Date start,
String jsonText,
ValueMap json)
|
protected void |
handleWhenCSSLoaded(String jsonText,
ValueMap json)
|
boolean |
hasActiveRequest()
Indicates whether or not there are currently active UIDL requests. |
boolean |
hasEventListeners(Paintable paintable,
String eventIdentifier)
Checks if there is a registered server side listener for the event. |
void |
init(WidgetSet widgetSet,
ApplicationConfiguration cnf)
|
static boolean |
isDebugMode()
Deprecated. use ApplicationConfiguration isDebugMode instead. |
boolean |
isLoadingIndicatorVisible()
Determines whether or not the loading indicator is showing. |
protected void |
makeUidlRequest(String requestData,
String extraParams,
boolean forceSync)
Makes an UIDL request to the server. |
void |
registerPaintable(String pid,
Paintable paintable)
|
void |
registerTooltip(Paintable paintable,
Object key,
TooltipInfo tooltip)
If component has several tooltips in addition to the one provided by AbstractComponent , component can register them with
this method. |
protected void |
repaintAll()
|
void |
requestLayoutPhase()
Components can call this function to run all layout functions. |
void |
resetCachedSize(Paintable p)
Removes the cached size info for the paintable. |
void |
runDescendentsLayout(com.google.gwt.user.client.ui.HasWidgets container)
Causes a re-calculation/re-layout of all paintables in a container. |
void |
sendPendingVariableChanges()
This method sends currently queued variable changes to server. |
void |
sendPendingVariableChangesSync()
This method assures that all pending variable changes are sent to server. |
void |
setWindowName(String newName)
Reset the name of the current browser-window. |
protected void |
showAuthenticationError(String details)
Shows the authentication error notification. |
protected void |
showCommunicationError(String details)
Deprecated. Use the method with errorCode instead |
protected void |
showCommunicationError(String details,
int statusCode)
Shows the communication error notification. |
void |
start()
Starts this application. |
protected void |
startRequest()
|
String |
translateVaadinUri(String uidlUri)
Translates custom protocols in UIDL URI's to be recognizable by browser. |
void |
unregisterChildPaintables(com.google.gwt.user.client.ui.HasWidgets container)
Unregisters a paintable and all it's child paintables recursively. |
void |
unregisterPaintable(Paintable p)
Unregisters the given paintable; always use after removing a paintable. |
boolean |
updateComponent(com.google.gwt.user.client.ui.Widget component,
UIDL uidl,
boolean manageCaption)
Update generic component features. |
void |
updateVariable(String paintableId,
String variableName,
boolean newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
double newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
float newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
int newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
long newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
Map<String,Object> map,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
Object[] values,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
Paintable newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
String[] values,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
void |
updateVariable(String paintableId,
String variableName,
String newValue,
boolean immediate)
Sends a new value for the given paintables given variable to the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String GENERATED_BODY_CLASSNAME
public static final String DISABLED_CLASSNAME
public static final char VAR_RECORD_SEPARATOR
public static final char VAR_FIELD_SEPARATOR
public static final char VAR_BURST_SEPARATOR
public static final char VAR_ARRAYITEM_SEPARATOR
public static final char VAR_ESCAPE_CHARACTER
public static final String UIDL_SECURITY_TOKEN_ID
@Deprecated public static final String UIDL_SECURITY_HEADER
public static final String PARAM_UNLOADBURST
public static final String ATTRIBUTE_DESCRIPTION
public static final String ATTRIBUTE_ERROR
public static final String UIDL_REFRESH_TOKEN
This allows, for instance, a servlet filter to redirect the application to a custom login page when the session expires. For example:
if (sessionExpired) { response.setHeader("Content-Type", "text/html"); response.getWriter().write( myLoginPageHtml + "<!-- Vaadin-Refresh: " + request.getContextPath() + " -->"); }
protected boolean applicationRunning
protected int lastProcessingTime
protected int totalProcessingTime
Constructor Detail |
---|
public ApplicationConnection()
Method Detail |
---|
public void init(WidgetSet widgetSet, ApplicationConfiguration cnf)
public void start()
ApplicationConfiguration.startNextApplication()
, which should be
called once this application has started (first response received) or
failed to start. This ensures that the applications are started in order,
to avoid session-id problems.
protected void extendLiferaySession()
@Deprecated public static Console getConsole()
VConsole
since 6.4.5
@Deprecated public static boolean isDebugMode()
public String getAppUri()
public boolean hasActiveRequest()
protected void repaintAll()
public void analyzeLayouts()
protected void makeUidlRequest(String requestData, String extraParams, boolean forceSync)
requestData
- Data that is passed to the server.extraParams
- Parameters that are added as GET parameters to the url.
Contains key=value pairs joined by & characters or is empty if
no parameters should be added. Should not start with any
special character.forceSync
- true if the request should be synchronous, false otherwiseprotected void doUidlRequest(String uri, String payload, boolean synchronous)
uri
- The URI to use for the request. May includes GET parameterspayload
- The contents of the request to sendsynchronous
- true if the request should be synchronous, false otherwiseprotected void doAsyncUIDLRequest(String uri, String payload, com.google.gwt.http.client.RequestCallback requestCallback) throws com.google.gwt.http.client.RequestException
uri
- The URI to use for the request. May includes GET parameterspayload
- The contents of the request to sendrequestCallback
- The handler for the response
com.google.gwt.http.client.RequestException
- if the request could not be sentprotected void handleWhenCSSLoaded(String jsonText, ValueMap json)
@Deprecated protected void showCommunicationError(String details)
details
- Optional details for debugging.protected void showCommunicationError(String details, int statusCode)
details
- Optional details for debugging.statusCode
- The http error code during the problematic request or -1 if
error happened before response was received.protected void showAuthenticationError(String details)
details
- Optional details for debugging.protected void startRequest()
protected void endRequest()
public boolean isLoadingIndicatorVisible()
protected void handleUIDLMessage(Date start, String jsonText, ValueMap json)
public void sendPendingVariableChangesSync()
public void registerPaintable(String pid, Paintable paintable)
public String getPid(Paintable paintable)
The paintableId is used in the UIDL to identify a specific widget instance, effectively linking the widget with it's server side Component.
paintable
- the paintable who's id is needed
public String getPid(com.google.gwt.user.client.Element el)
getPid(Paintable)
instead whenever possible.
el
- element of the paintable whose pid is desired
getPid(Paintable)
public com.google.gwt.user.client.Element getElementByPid(String pid)
getPid(Element)
.
pid
- the pid of the widget whose element is desired
public void unregisterPaintable(Paintable p)
p
- the paintable to removepublic void unregisterChildPaintables(com.google.gwt.user.client.ui.HasWidgets container)
container
- unregisterPaintable(Paintable)
public Paintable getPaintable(String id)
id
- Paintable IDpublic void sendPendingVariableChanges()
public void updateVariable(String paintableId, String variableName, Paintable newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, String newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, int newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, long newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, float newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, double newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, boolean newValue, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, Map<String,Object> map, boolean immediate)
The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, String[] values, boolean immediate)
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possiblepublic void updateVariable(String paintableId, String variableName, Object[] values, boolean immediate)
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possibleprotected String escapeVariableValue(String value)
value
- to encode
public boolean updateComponent(com.google.gwt.user.client.ui.Widget component, UIDL uidl, boolean manageCaption)
The implementation of a component depends on many properties, including styles, component features, etc. Sometimes the user changes those properties after the component has been created. Calling this method in the beginning of your updateFromUIDL -method automatically replaces your component with more appropriate if the requested implementation changes.
Component can delegate management of caption, icon, error messages and description to parent layout. This is optional an should be decided by component author
component
- Widget to be updated, expected to implement an instance of
Paintableuidl
- UIDL to be paintedmanageCaption
- True if you want to delegate caption, icon, description and
error message management to parent.
public static String getStyleName(String primaryStyleName, UIDL uidl, boolean field)
primaryStyleName
- uidl
- isField
-
public void runDescendentsLayout(com.google.gwt.user.client.ui.HasWidgets container)
container
- public void forceLayout()
public boolean handleComponentRelativeSize(com.google.gwt.user.client.ui.Widget child)
child
-
public RenderInformation.FloatSize getRelativeSize(com.google.gwt.user.client.ui.Widget widget)
widget
- the paintable whose size is needed
public Paintable getPaintable(UIDL uidl)
uidl
- UIDL to create Paintable from.
public Paintable getPaintable(com.google.gwt.user.client.Element element)
element
- Root element of the paintablepublic String getResource(String name)
name
- identifier of the resource to get
public VContextMenu getContextMenu()
public String translateVaadinUri(String uidlUri)
uidlUri
- Vaadin URI from uidl
public String getThemeUri()
public TooltipInfo getTooltipTitleInfo(Paintable titleOwner, Object key)
public void handleTooltipEvent(com.google.gwt.user.client.Event event, Paintable owner)
event
- owner
- public void handleTooltipEvent(com.google.gwt.user.client.Event event, Paintable owner, Object key)
event
- owner
- key
- the key for tooltip if this is "additional" tooltip, null for
components "main tooltip"public void addPngFix(com.google.gwt.user.client.Element el)
el
- the IMG element to fixpublic void requestLayoutPhase()
public void setWindowName(String newName)
stringAttribute
- New name for the window.protected String getWindowName()
protected String getUidlSecurityKey()
public void captionSizeUpdated(Paintable component)
component
- the Paintable whose caption has changedpublic VView getView()
public void registerTooltip(Paintable paintable, Object key, TooltipInfo tooltip)
AbstractComponent
, component can register them with
this method.
Component must also pipe events to
handleTooltipEvent(Event, Paintable, Object)
method.
This method can also be used to deregister tooltips by using null as tooltip
paintable
- Paintable "owning" this tooltipkey
- key assosiated with given tooltip. Can be any object. For
example a related dom element. Same key must be given for
handleTooltipEvent(Event, Paintable, Object)
method.tooltip
- the TooltipInfo object containing details shown in tooltip,
null if deregistering tooltippublic ApplicationConfiguration getConfiguration()
ApplicationConfiguration
for the current application.
ApplicationConfiguration
public boolean hasEventListeners(Paintable paintable, String eventIdentifier)
eventIdentifier
- The identifier for the event
public static String addGetParameters(String uri, String extraParams)
uri
- The uri to which the parameters should be added.extraParams
- One or more parameters in the format "a=b" or "c=d&e=f". An
empty string is allowed but will not modify the url.
public void resetCachedSize(Paintable p)
p
- The paintable whose cached size info should be discarded
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |