public interface ItsNatDocument extends ItsNatUserData
org.w3c.dom.Document
object. Usually represents a web page
loaded by a client.
Provides many useful utilities to simulate "The Browser Is The Server" approach of ItsNat like event listener registries. Is the factory of DOM utility objects and ItsNat components.
ItsNat document objects are created using a ItsNatDocumentTemplate
as pattern and
usually obtained calling ItsNatServletRequest.getItsNatDocument()
or ItsNatServletResponse.getItsNatDocument()
when a new document (page) is loading or calling ItsNatEvent.getItsNatDocument()
when an event is received.
Is not thread save and any object depending on this document (DOM utility objects, components etc) is not thread save too. This is not a problem because any ItsNat request/response thread synchronizes this object before calling user defined code, user defined code executed by an ItsNat request/response thread may be unaware of synchronization isues.
Modifier and Type | Method and Description |
---|---|
void |
addCodeToSend(java.lang.Object code)
Add JavaScript code to send to any client (owner or remote control) bound to this document (pending code).
|
void |
addCodeToSendListener(CodeToSendListener listener)
Registers a new
CodeToSendListener , this listener is called
every time addCodeToSend(Object) is called. |
void |
addEventListener(org.w3c.dom.events.EventListener listener)
Adds a global event listener to this document.
|
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
Registers a new DOM
org.w3c.dom.events.EventListener with the
document default communication mode and timeout, no extra parameters and no custom JavaScript code. |
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
int commMode)
Registers a new DOM
org.w3c.dom.events.EventListener with no extra
parameters and no custom JavaScript code, and document default event timeout. |
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
int commMode,
ParamTransport[] extraParams,
java.lang.String preSendCode,
long eventTimeout)
Registers a new DOM
org.w3c.dom.events.EventListener . |
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
ParamTransport extraParam)
Registers a new DOM
org.w3c.dom.events.EventListener with
document default communication mode and timeout, the specified extra
parameter and no custom JavaScript code. |
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
ParamTransport[] extraParams)
Registers a new DOM
org.w3c.dom.events.EventListener with
document default communication mode and timeout, the specified extra
parameters and no custom JavaScript code. |
void |
addEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
java.lang.String preSendCode)
Registers a new DOM
org.w3c.dom.events.EventListener with
document default communication mode and event timeout, no extra
parameters and the specified custom JavaScript code. |
void |
addItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener listener)
Adds a remote control listener to this document.
|
void |
addMutationEventListener(org.w3c.dom.events.EventTarget target,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
Registers a new DOM
org.w3c.dom.events.EventListener to receive any node mutation
as a mutation event fired by the client, using the default communication mode and timeout of the document
and no custom JavaScript code. |
void |
addMutationEventListener(org.w3c.dom.events.EventTarget target,
org.w3c.dom.events.EventListener listener,
boolean useCapture,
int commMode,
java.lang.String preSendCode,
long eventTimeout)
Registers a new DOM
org.w3c.dom.events.EventListener to receive any node mutation
as a mutation event fired by the client. |
void |
addReferrerItsNatServletRequestListener(ItsNatServletRequestListener listener)
Registers a new ItsNat referrer request listener.
|
void |
addUserEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String name,
org.w3c.dom.events.EventListener listener)
Registers a "user"
EventListener . |
void |
addUserEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String name,
org.w3c.dom.events.EventListener listener,
int commMode,
ParamTransport[] extraParams,
java.lang.String preSendCode,
long eventTimeout)
Registers a "user"
EventListener . |
org.w3c.dom.events.Event |
createEvent(java.lang.String eventType)
Create a remote event to be dispatched locally or to the client.
|
ItsNatVariableResolver |
createItsNatVariableResolver()
Creates a variable resolver bound to this document.
|
ItsNatVariableResolver |
createItsNatVariableResolver(boolean disconnected)
Creates a variable resolver bound to this document if the
disconnected
parameter is set to false. |
void |
disableSendCode()
Disables the
addCodeToSend(Object) method, no new code can be added
to send to the client. |
org.w3c.dom.Node |
disconnectChildNodesFromClient(org.w3c.dom.Node node)
Removes the child nodes of the specified node to save server memory but not in client.
|
boolean |
dispatchEvent(org.w3c.dom.events.EventTarget target,
org.w3c.dom.events.Event evt)
Dispatches the specified event to the specified node target.
|
boolean |
dispatchEventLocally(org.w3c.dom.events.EventTarget target,
org.w3c.dom.events.Event evt)
Dispatches the specified event to the specified node target directly on the server.
|
void |
enableSendCode()
Enables the
addCodeToSend(Object) method, new code can be added
to send to the client. |
java.lang.Object |
getArtifact(java.lang.String name)
Returns the artifact with the specified name.
|
java.lang.Object |
getArtifact(java.lang.String name,
boolean cascade)
Returns the artifact with the specified name.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value associated to the specified attribute name.
|
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Returns an enumeration with the registered attribute names and values.
|
ClientDocument |
getClientDocumentOwner()
Returns the document proxy of the owner of this document.
|
int |
getCommMode()
Returns the default communication mode, AJAX or SCRIPT, for events.
|
org.w3c.dom.Node |
getContainerNode()
Returns the node containing this document.
|
long |
getCreationTime()
Returns the time in milliseconds when this object was created.
|
java.text.DateFormat |
getDefaultDateFormat()
Returns the default data format used by components such as
ItsNatHTMLInputTextFormatted . |
java.text.NumberFormat |
getDefaultNumberFormat()
Returns the default number format used by components such as
ItsNatHTMLInputTextFormatted . |
org.w3c.dom.Document |
getDocument()
Returns the
org.w3c.dom.Document wrapped by this object. |
ElementGroupManager |
getElementGroupManager()
Returns the element group manager utility.
|
long |
getEventDispatcherMaxWait()
Returns the default max wait until a server fired event calling
ClientDocument.dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event,int,long)
is processed by the client and returns. |
long |
getEventTimeout()
Returns the default timeout in client of asynchronous AJAX/SCRIPT events.
|
java.lang.String |
getId()
Returns the client identity.
|
ItsNatComponentManager |
getItsNatComponentManager()
Returns the component manager utility.
|
ItsNatDocumentTemplate |
getItsNatDocumentTemplate()
Returns the template this document is based on.
|
int |
getMaxOpenClientsByDocument()
Returns the max number of open clients (owner and attached) associated to a document in server.
|
ScriptUtil |
getScriptUtil()
Returns the scripting utility.
|
boolean |
isCreatedByStatelessEvent()
If this document was created when processing a stateless event, that is, it was loaded as the result of processing a stateless event fired with a JavaScript call
document.getItsNatDoc().dispatchEventStateless(...); provided a
itsnat_doc_name parameter. |
boolean |
isDisconnectedChildNodesFromClient(org.w3c.dom.Node node)
Informs whether the specified node is marked as "child nodes disconnected"
|
boolean |
isInvalid()
Informs whether this document is invalid.
|
boolean |
isJoystickMode()
Informs whether a joystick is enough to control, for instance, components
(some kind of mouse, pointer or stylus not present or not necessary).
|
boolean |
isLoading()
Informs whether this document is in the load phase.
|
boolean |
isSendCodeEnabled()
Informs whether JavaScript code can be added to send to the client
calling
addCodeToSend(Object) |
boolean |
isUsePatternMarkupToRender()
Informs whether dom utils and components use by default the original
(saved as pattern) markup to render.
|
void |
reconnectChildNodesToClient(org.w3c.dom.Node node)
Reconnects further new child nodes of the specified node with the client, the child nodes in client are removed
and again the client will be in sync with server.
|
void |
registerArtifact(java.lang.String name,
java.lang.Object value)
Registers an artifact with the specified name.
|
java.lang.Object |
removeArtifact(java.lang.String name)
Removes the artifact with the specified name.
|
void |
removeAttribute(java.lang.String name)
Unregisters the specified attribute with the given name.
|
void |
removeCodeToSendListener(CodeToSendListener listener)
Removes a previously registered
CodeToSendListener . |
void |
removeEventListener(org.w3c.dom.events.EventListener listener)
Removes the specified global event listener registered in this document.
|
void |
removeEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
Removes the listener registration with the specified node target, name, listener and capture.
|
void |
removeItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener listener)
Removes the specified remote control listener.
|
void |
removeMutationEventListener(org.w3c.dom.events.EventTarget target,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
Removes the mutation listener registration with the specified node target, listener and capture.
|
void |
removeReferrerItsNatServletRequestListener(ItsNatServletRequestListener listener)
Unregisters the specified user defined referrer request listener.
|
void |
removeUserEventListener(org.w3c.dom.events.EventTarget target,
java.lang.String name,
org.w3c.dom.events.EventListener listener)
Removes the listener registration with the specified node target, name and listener.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Registers the specified attribute name and value.
|
void |
setCommMode(int commMode)
Sets the default communication mode, AJAX or SCRIPT, for events.
|
void |
setDefaultDateFormat(java.text.DateFormat format)
Sets the default data format used by components such as
ItsNatHTMLInputTextFormatted . |
void |
setDefaultNumberFormat(java.text.NumberFormat format)
Sets the default data format used by components such as
ItsNatHTMLInputTextFormatted . |
void |
setEventDispatcherMaxWait(long wait)
Sets the default max wait until a server fired event with
ClientDocument.dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event,int,long)
is processed by the client and returns. |
void |
setEventTimeout(long timeout)
Sets the default timeout of asynchronous AJAX/SCRIPT events.
|
void |
setInvalid()
Sets this document as invalid.
|
void |
setJoystickMode(boolean value)
Informs whether a joystick is enough to control, for instance, components
(some kind of mouse, pointer or stylus not present or not necessary).
|
void |
setMaxOpenClientsByDocument(int value)
Sets the max number of open clients (owner and attached) associated to a document in server.
|
void |
setUsePatternMarkupToRender(boolean value)
Sets whether dom utils and components use by default the original
(saved as pattern) markup to render.
|
org.w3c.dom.DocumentFragment |
toDOM(java.lang.String code)
Parses and converts to DOM the specified string containing markup
usually to be inserted into the document.
|
containsUserValueName, getUserValue, getUserValueNames, removeUserValue, setUserValue
java.lang.String getId()
ItsNatSession
and never reused in this context.
The identity value is unique no other session-identified object in the same session shares the same id.
Although this object is garbage collected, the identity value is never reused by another session-identified object in the same session.
org.w3c.dom.Node getContainerNode()
This method returns a non-null object if this document was loaded using an <iframe> or <object> or <embed> following the automatic binding technique (the data or src attribute has the format "?itsnat_doc_name=docName&...").
The returned node is owned by a different DOM document (the parent document of this document),
use Document.importNode(Node,boolean)
to migrate nodes between documents.
Use ItsNatNode.getItsNatDocument()
to get the parent ItsNat document
ItsNat documents and dependent objects are single threaded, ItsNat automatically locks the document associated to the web request thread and parent documents, in this case synchronization is not needed.
int getCommMode()
The default value is defined by ItsNatDocumentTemplate.getCommMode()
This feature only affects to non-XML documents with events enabled.
setCommMode(int)
,
CommMode
void setCommMode(int commMode)
commMode
- the new communication mode.getCommMode()
long getEventTimeout()
When an unfinished request takes more time than the specified timeout, the request is aborted.
The default value is defined by ItsNatDocumentTemplate.getEventTimeout()
This feature only affects non-XML documents with events enabled and is ignored in synchronous AJAX events.
setEventTimeout(long)
void setEventTimeout(long timeout)
timeout
- the new timeout. If negative no timeout is defined.getEventTimeout()
java.text.DateFormat getDefaultDateFormat()
ItsNatHTMLInputTextFormatted
.
The default value is defined by ItsNatDocumentTemplate.getDefaultDateFormat()
setDefaultDateFormat(DateFormat)
void setDefaultDateFormat(java.text.DateFormat format)
ItsNatHTMLInputTextFormatted
.format
- the default data format.getDefaultDateFormat()
java.text.NumberFormat getDefaultNumberFormat()
ItsNatHTMLInputTextFormatted
.
The default value is defined by ItsNatDocumentTemplate.getDefaultNumberFormat()
setDefaultNumberFormat(NumberFormat)
void setDefaultNumberFormat(java.text.NumberFormat format)
ItsNatHTMLInputTextFormatted
.format
- the default data format.getDefaultNumberFormat()
long getEventDispatcherMaxWait()
ClientDocument.dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event,int,long)
is processed by the client and returns.
The default value is defined by ItsNatDocumentTemplate.getEventDispatcherMaxWait()
This feature only affects non-XML documents with events enabled.
setEventDispatcherMaxWait(long)
void setEventDispatcherMaxWait(long wait)
ClientDocument.dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event,int,long)
is processed by the client and returns.wait
- the default max wait in milliseconds.getEventDispatcherMaxWait()
int getMaxOpenClientsByDocument()
This feature only affects to non-XML documents with events enabled
The default value is defined by ItsNatDocumentTemplate.getMaxOpenClientsByDocument()
void setMaxOpenClientsByDocument(int value)
value
- the new max number of open clients.getMaxOpenClientsByDocument()
boolean isUsePatternMarkupToRender()
The default value is defined by ItsNatDocumentTemplate.isUsePatternMarkupToRender()
setUsePatternMarkupToRender(boolean)
void setUsePatternMarkupToRender(boolean value)
value
- true to enable the use of original markup to render.isUsePatternMarkupToRender()
boolean isJoystickMode()
The default value is defined by ItsNatDocumentTemplate.isJoystickMode()
This feature only affects to non-XML documents with events enabled.
setJoystickMode(boolean)
,
ItsNatFreeList.isJoystickMode()
,
ItsNatTable.isJoystickMode()
,
ItsNatTree.isJoystickMode()
void setJoystickMode(boolean value)
This method does not change the current state of already created components but may be the default value of new components with this feature.
value
- true to enable joystick mode.isJoystickMode()
boolean isCreatedByStatelessEvent()
itsnat_doc_name
parameter.org.w3c.dom.DocumentFragment toDOM(java.lang.String code)
The specified markup must not be a complete document and must be a well-formatted markup fragment.
This method does not perform caching, markup code is ever parsed from the scratch. Use with small markup fragments. For very small fragments use normal DOM methods and for big fragments use the fragment templating system.
Be careful with the security using this method when the string is constructed containing user data. For instance, a malicious user can add unexpected elements like <script>, <link> or <object>. This is not the recommended approach, insert user provided data using DOM APIs after this call.
code
- the markup to parse and convert to DOMItsNatDocumentTemplate getItsNatDocumentTemplate()
org.w3c.dom.Document getDocument()
org.w3c.dom.Document
wrapped by this object.ClientDocument getClientDocumentOwner()
ScriptUtil getScriptUtil()
ItsNatComponentManager getItsNatComponentManager()
boolean isLoading()
ItsNatServletRequestListener.processRequest(ItsNatServletRequest,ItsNatServletResponse)
boolean isInvalid()
The document is marked as invalid when is unloaded (no more attached to a browser document/page). XML documents are automatically invalidated after loading.
If invalid the document is not found anymore on session registry (ItsNatSession.getItsNatDocumentById(String)
).
setInvalid()
void setInvalid()
isInvalid()
java.lang.Object getAttribute(java.lang.String name)
This method is symmetric to
ServletRequest.getAttribute(String)
and
ServletContext.getAttribute(String)
.
The purpose is to provide a document level attribute registry to complement
ServletRequest
and ServletContext
attribute registries.
Is called by ItsNatVariableResolver.getVariable(String)
when the variable resolver was created using createItsNatVariableResolver()
and does not contain the specified variable name.
name
- the attribute name to search.setAttribute(String,Object)
,
getAttributeNames()
,
removeAttribute(String)
void setAttribute(java.lang.String name, java.lang.Object value)
This method is symmetric to
ServletRequest.setAttribute(String,Object)
and
ServletContext.setAttribute(String,Object)
.
name
- the attribute name.value
- the attribute value.getAttribute(String)
java.util.Enumeration<java.lang.String> getAttributeNames()
This method is symmetric to
ServletRequest.getAttributeNames()
and
ServletContext.getAttributeNames()
.
getAttribute(String)
void removeAttribute(java.lang.String name)
This method is symmetric to
ServletRequest.removeAttribute(String)
and
ServletContext.removeAttribute(String)
.
name
- the attribute name.getAttribute(String)
ItsNatVariableResolver createItsNatVariableResolver()
createItsNatVariableResolver(boolean)
ItsNatVariableResolver createItsNatVariableResolver(boolean disconnected)
disconnected
parameter is set to false.
Set disconnected
as true if only local variables of
the returned variable resolver must be used
(this avoids any attempt to resolve unexpected variables in markup).
disconnected
- if the new variable resolver is disconnected from the document.createItsNatVariableResolver()
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
org.w3c.dom.events.EventListener
with the
document default communication mode and timeout, no extra parameters and no custom JavaScript code.target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean )
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture, int commMode)
org.w3c.dom.events.EventListener
with no extra
parameters and no custom JavaScript code, and document default event timeout.target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).commMode
- communication mode.addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean ,int )
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture, ParamTransport extraParam)
org.w3c.dom.events.EventListener
with
document default communication mode and timeout, the specified extra
parameter and no custom JavaScript code.target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).extraParam
- client to server data transport and synchronization rule.addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean ,ParamTransport )
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture, ParamTransport[] extraParams)
org.w3c.dom.events.EventListener
with
document default communication mode and timeout, the specified extra
parameters and no custom JavaScript code.target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).extraParams
- client to server data transport and synchronization rules.addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean ,ParamTransport[] )
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture, java.lang.String preSendCode)
org.w3c.dom.events.EventListener
with
document default communication mode and event timeout, no extra
parameters and the specified custom JavaScript code.target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).preSendCode
- custom JavaScript code to execute before an event of this listener type is fired.addEventListener(EventTarget,String,EventListener,boolean,int,ParamTransport[],String,long)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean ,String )
void addEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture, int commMode, ParamTransport[] extraParams, java.lang.String preSendCode, long eventTimeout)
org.w3c.dom.events.EventListener
.
When this listener is registered the server sends custom JavaScript code to register
a handler in the client side with the specified node target and DOM event type.
When an event is fired this handler forwards the client event to the server
and the registered listener receives an org.w3c.dom.events.Event
with
the same client event data.
If two or more listeners are registered sharing the same node target and event type, they all will receive the same event.
target
- target element. Can not be null.type
- the DOM event type name (click, change etc).listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).commMode
- communication mode.extraParams
- optional client to server data transport and synchronization rules. May be null.preSendCode
- custom JavaScript code to execute before an event of this listener type is fired. May be null.eventTimeout
- the timeout of asynchronous events. If negative no timeout is defined.removeEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean)
,
ClientDocument.addEventListener(EventTarget ,String ,EventListener ,boolean ,int ,ParamTransport[] ,String ,long )
,
CommMode
void removeEventListener(org.w3c.dom.events.EventTarget target, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
target
- the target element. Can not be null.type
- the DOM event type name.listener
- the registered listener.useCapture
- event capture mode.addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.removeEventListener(org.w3c.dom.events.EventTarget, java.lang.String, org.w3c.dom.events.EventListener, boolean)
void addMutationEventListener(org.w3c.dom.events.EventTarget target, org.w3c.dom.events.EventListener listener, boolean useCapture)
org.w3c.dom.events.EventListener
to receive any node mutation
as a mutation event fired by the client, using the default communication mode and timeout of the document
and no custom JavaScript code.target
- target element. Can not be null.listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).addMutationEventListener(org.w3c.dom.events.EventTarget,org.w3c.dom.events.EventListener,boolean,int,String,long)
,
ClientDocument.addMutationEventListener(org.w3c.dom.events.EventTarget, org.w3c.dom.events.EventListener, boolean)
void addMutationEventListener(org.w3c.dom.events.EventTarget target, org.w3c.dom.events.EventListener listener, boolean useCapture, int commMode, java.lang.String preSendCode, long eventTimeout)
org.w3c.dom.events.EventListener
to receive any node mutation
as a mutation event fired by the client.
When a mutation event is received, this event carries the necessary data to synchronize the server target element with the client. After this automatic synchronization, the listener is called.
Current implementation does the following:
ParamTransport[] params = new ParamTransport[]{ new ClientMutation() }; addEventListener(target,"DOMAttrModified",listener,useCapture,commMode,params,preSendCode,eventTimeout); addEventListener(target,"DOMNodeInserted",listener,useCapture,commMode,params,preSendCode,eventTimeout); addEventListener(target,"DOMNodeRemoved",listener,useCapture,commMode,params,preSendCode,eventTimeout); addEventListener(target,"DOMCharacterDataModified",listener,useCapture,commMode,params,preSendCode,eventTimeout);
If the target is the org.w3c.dom.Document
object, every document change in the client
is automatically synchronized in the server.
Mutation events only works with some W3C browses like Mozilla/FireFox, Safari and Opera (MSIE 6 does not support W3C DOM mutation events).
target
- target element. Can not be null.listener
- the listener to receive events.useCapture
- if event capture is enabled. False is the most portable value (MSIE v6 does not support event capture).commMode
- communication mode.preSendCode
- custom JavaScript code to execute before an event of this listener type is fired. May be null.eventTimeout
- the timeout of asynchronous events. If negative no timeout is defined.removeMutationEventListener(org.w3c.dom.events.EventTarget,org.w3c.dom.events.EventListener,boolean)
,
addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addMutationEventListener(EventTarget ,EventListener ,boolean ,int ,String ,long )
void removeMutationEventListener(org.w3c.dom.events.EventTarget target, org.w3c.dom.events.EventListener listener, boolean useCapture)
target
- the target element. Can not be null.listener
- the registered listener.useCapture
- event capture mode.addMutationEventListener(org.w3c.dom.events.EventTarget,org.w3c.dom.events.EventListener,boolean,int,String,long)
,
ClientDocument.removeMutationEventListener(EventTarget ,EventListener ,boolean )
void addUserEventListener(org.w3c.dom.events.EventTarget target, java.lang.String name, org.w3c.dom.events.EventListener listener, int commMode, ParamTransport[] extraParams, java.lang.String preSendCode, long eventTimeout)
EventListener
.
When this listener is registered the server sends custom JavaScript code to register a handler in the client side with the specified node target and name.
User events are fired in the client calling the ItsNat JavaScript method
fireUserEvent(targetNode,name)
or dispatchUserEvent(targetNode,evt)
(where evt
is a special user event see Manual for more info).
For instance:
document.getItsNatDoc().fireUserEvent(document.body,"myUserAction");
Target node and name must be the same parameters used to register the listener.
If two or more listeners are registered sharing the same node target and name,
they all will receive the same event fired by fireUserEvent
with this
target/name pair. If a listener instance was already registered and is registered again
with the same target and name, this second call does nothing.
target
- target element. Can not be null.name
- the user defined event type name.listener
- the listener to receive events.commMode
- communication mode.extraParams
- optional client to server data transport and synchronization rules. May be null.preSendCode
- custom JavaScript code to execute before an event of this listener type is fired. May be null.eventTimeout
- the timeout of asynchronous events. If negative no timeout is defined.removeUserEventListener(org.w3c.dom.events.EventTarget,String,EventListener)
,
addEventListener(org.w3c.dom.events.EventTarget,String,org.w3c.dom.events.EventListener,boolean,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.addUserEventListener(org.w3c.dom.events.EventTarget, java.lang.String, org.w3c.dom.events.EventListener, int, org.itsnat.core.event.ParamTransport[], java.lang.String, long)
,
CommMode
void addUserEventListener(org.w3c.dom.events.EventTarget target, java.lang.String name, org.w3c.dom.events.EventListener listener)
EventListener
.
This method calls addUserEventListener(EventTarget,String,EventListener,int,ParamTransport[],String,long)
with the document default values (communication mode, event timeout) and no extra parameters and custom code.
target
- target element. Can not be null.name
- the user defined event type name.listener
- the listener to receive events.ClientDocument.addUserEventListener(EventTarget ,String ,EventListener )
void removeUserEventListener(org.w3c.dom.events.EventTarget target, java.lang.String name, org.w3c.dom.events.EventListener listener)
target
- the target element. Can not be null.name
- the user defined event type name.listener
- the registered listener.addUserEventListener(org.w3c.dom.events.EventTarget,String,EventListener,int,org.itsnat.core.event.ParamTransport[],String,long)
,
ClientDocument.removeUserEventListener(EventTarget ,String ,EventListener)
void addEventListener(org.w3c.dom.events.EventListener listener)
The listener is called before calling any DOM event listener registered in this document. This listener registry is passive, in no way the client is modified (no listener is registered on the client) and usually used for monitoring.
listener
- the listener to add.removeEventListener(EventListener)
,
ItsNatServlet.addEventListener(EventListener)
,
ItsNatDocumentTemplate.addEventListener(EventListener)
,
ClientDocument.addEventListener(org.w3c.dom.events.EventListener)
void removeEventListener(org.w3c.dom.events.EventListener listener)
listener
- the listener to remove.addEventListener(EventListener)
,
ClientDocument.removeEventListener(org.w3c.dom.events.EventListener)
void addCodeToSend(java.lang.Object code)
ClientDocument.addCodeToSend(Object)
.code
- the code to send, Object.toString()
is called to convert to string.ItsNatException
- if no code can be added.isSendCodeEnabled()
,
ScriptUtil
boolean isSendCodeEnabled()
addCodeToSend(Object)
disableSendCode()
void disableSendCode()
addCodeToSend(Object)
method, no new code can be added
to send to the client.enableSendCode()
void enableSendCode()
addCodeToSend(Object)
method, new code can be added
to send to the client.disableSendCode()
void addCodeToSendListener(CodeToSendListener listener)
CodeToSendListener
, this listener is called
every time addCodeToSend(Object)
is called.listener
- the new listener.removeCodeToSendListener(CodeToSendListener)
void removeCodeToSendListener(CodeToSendListener listener)
CodeToSendListener
.listener
- the new listener.addCodeToSendListener(CodeToSendListener)
ElementGroupManager getElementGroupManager()
void registerArtifact(java.lang.String name, java.lang.Object value)
name
- the artifact namevalue
- the artifact.getArtifact(String)
,
removeArtifact(String)
,
NameValue
java.lang.Object getArtifact(java.lang.String name)
name
- the artifact name to look for.registerArtifact(String,Object)
,
getArtifact(String,boolean)
java.lang.Object removeArtifact(java.lang.String name)
name
- the artifact name to look for.registerArtifact(String,Object)
java.lang.Object getArtifact(java.lang.String name, boolean cascade)
If no artifact is found and cascade
is true,
the method ItsNatDocumentTemplate.getArtifact(String,boolean)
is called with cascade
set to true to continue searching.
name
- the artifact name to look for.getArtifact(String)
void addItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener listener)
listener
- the listener to add.removeItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener)
,
ItsNatServlet.addItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener)
,
ItsNatDocumentTemplate.addItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener)
void removeItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener listener)
listener
- the listener to remove.addItsNatAttachedClientEventListener(ItsNatAttachedClientEventListener)
org.w3c.dom.events.Event createEvent(java.lang.String eventType) throws org.w3c.dom.DOMException
This method works the same as org.w3c.dom.events.Document.createEvent(String)
,
in this case the event object created is ready to be dispatched to the
remote event listeners registered calling:
EventTarget.dispatchEvent(Event)
: this method detects
whether the submitted event was created by this factory method then redirects
to dispatchEvent(EventTarget,Event)
.
dispatchEvent(EventTarget,Event)
dispatchEventLocally(EventTarget,Event)
ClientDocument.dispatchEvent(EventTarget,Event)
eventType
- The eventType
parameter specifies the
type of Event
interface to be created.org.w3c.dom.DOMException
boolean dispatchEvent(org.w3c.dom.events.EventTarget target, org.w3c.dom.events.Event evt) throws org.w3c.dom.events.EventException
If the current thread was not started calling ClientDocument.startEventDispatcherThread(Runnable)
current implementation calls dispatchEventLocally(EventTarget,Event)
,
otherwise calls ClientDocument.dispatchEvent(EventTarget,Event)
.
This method is called by org.w3c.dom.events.EventTarget#dispatchEvent(Event)
when the event object was created calling createEvent(String)
.
target
- the event target DOM object.evt
- the DOM event to send to target.org.w3c.dom.events.EventException
boolean dispatchEventLocally(org.w3c.dom.events.EventTarget target, org.w3c.dom.events.Event evt) throws org.w3c.dom.events.EventException
The event is routed across the server DOM tree and dispatched to listeners as specified by the W3C DOM Events standard including bubbling and capturing.
target
- the event target DOM object.evt
- the DOM event to send to target.org.w3c.dom.events.EventException
long getCreationTime()
void addReferrerItsNatServletRequestListener(ItsNatServletRequestListener listener)
listener
- the listener to register.removeReferrerItsNatServletRequestListener(ItsNatServletRequestListener)
,
ItsNatDocumentTemplate.isReferrerPushEnabled()
void removeReferrerItsNatServletRequestListener(ItsNatServletRequestListener listener)
listener
- the listener to remove.addReferrerItsNatServletRequestListener(ItsNatServletRequestListener)
boolean isDisconnectedChildNodesFromClient(org.w3c.dom.Node node)
node
- the node to ask.disconnectChildNodesFromClient(Node)
,
reconnectChildNodesToClient(Node)
org.w3c.dom.Node disconnectChildNodesFromClient(org.w3c.dom.Node node)
After this call the child nodes in client are not longer in sync with server and can be freely manipulated (including insertion and removing).
The specified node is marked as "child nodes disconnected", the inmmediate call to
isDisconnectedChildNodesFromClient(Node)
will return true.
Returns the removed child nodes following the same criteria as ItsNatDOMUtil.extractChildren(Node)
.
If the content of the parent node is already disconnected or is a node not into the document
an ItsNatException
is thrown.
node
- the parent node which content is going to be disconnected and removed.reconnectChildNodesToClient(Node)
void reconnectChildNodesToClient(org.w3c.dom.Node node)
Further insertion of child nodes will be also effective in client.
This method is automatically/implicitly called by ItsNat when a node is inserted into a "child nodes disconnected" node, the node inserted then in also inserted into the client now in sync.
If the speficied node is not a "child nodes disconnected" node this call does nothing.
node
- the parent node which content will be in sync again with client.disconnectChildNodesFromClient(Node)
Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.