Good questions
First of all, I invite you to read the chapter 8 of Reference Manual on the new stateless mode
http://itsnat.sourceforge.net/php/support/docs/manual.pdfEl jueves, 20 de junio de 2013 05:59:04 UTC+2, Licky escribió:
I have a question on the showcase StlessGlobalEventListener class. 1. Why the event can direct cast to ItsNatEventStateless without checking?
2. In case itsNatEvt.getItsNatDocument() is null, why ClientDocument can be obtained by itsNatEvt.getClientDocument()?
ItsNatDocument is *usually* the symmetric document of client/browser page, this is not ever true, for instance in remote control the same ItsNatDocument is shared between users. Sometimes there is no such ItsNatDocument for instance when session is expired or similar, this is why sometimes we get null.
ClientDocument represents the client browser/page, this ClientDocument *ever* exists including in error cases, in old versions of ItsNat in some cases ClientDocument was null, I realized the client browser is "ever" there so ClientDocument is not null in spite of in some cases ClientDocument behavior is dummy for instance when there is no ItsNatDocument bound.
Usually there is 1 - 1 relationship between ClientDocument - ItsNatDocument, sometimes not, for instance in remote control (several clients sharing the same server doc), in this case when you call ItsNatDocument.addCodeToSend() you send custom JS code to all clients, and when you call ClientDocument.addCodeToSend() only the target client is involved.
3. May I know the clear difference and life cycle between ItsNatDocument, HTMLDocument, and ClientDocument?
ItsNatDocument is just a wrapper of the standard DOM Document object (HTMLDocument when HTML/XHTML, remember pure XML, SVG or XUL are possible), the lifecycle is the same.