Sub-Fragment Removal Problem

9 views
Skip to first unread message

Licky

unread,
Jun 20, 2013, 3:14:50 AM6/20/13
to its...@googlegroups.com
I just wonder what is the correct way to remove a fragment in the document.

From manual example: StatelessExampleForProcessingEventDocument class

Element elemParent = doc.getElementById("insertHereId");
ScriptUtil scriptGen = itsNatDoc.getScriptUtil();
String elemRef = scriptGen.getNodeReference(elemParent);
ClientDocument clientDoc = itsNatEvt.getClientDocument();
clientDoc.addCodeToSend(elemRef + ".innerHTML = '';");
clientDoc.addCodeToSend("alert('Currently inserted fragment removed before');");

It works without doubt.

However, if the coding changed as below, the fragment under "insertHereId" will not be removed.

Element elemParent = doc.getElementById("insertHereId");
ClientDocument clientDoc = itsNatEvt.getClientDocument();
ItsNatDOMUtil.removeAllChildren(elemParent);
clientDoc.addCodeToSend("alert('Currently inserted fragment removed before');");

jmar...@innowhere.com

unread,
Jun 21, 2013, 3:28:02 AM6/21/13
to its...@googlegroups.com
In stateless mode you can change your mind, is *different* to stateful mode, remember there is no ItsNatDocument in server in sync with client, you have the option to recreate the client state (fully or partially) in the load phase of the ItsNatDocument created to process the stateless event, in this example I recreate the element with the integer value, but in case of insertHereId the ItsNatDocument is recreated with no content in insertHereId element, in client this element has content, this is why I clean the client content with JS because I'm going to recreate the content, the example could be different filling the insertHereId content in load phase with the same content in client this what I did in the element with integer example, in insertHereId example I wanted to show an example of insertion of a "big" chunck of code, in my opinion ItsNat stateless mode typical use is to build/replace the big parts of the client page, finer control is also possible but the more fine changes the more interesting is JS.

Take a look the alternative stateless component based example, in this case the list is rebuilt in load phase.

Reply all
Reply to author
Forward
0 new messages