Hi<br><br><div class="gmail_quote">2010/8/13 Ed Burns <span dir="ltr">&lt;<a href="mailto:edward.burns@oracle.com">edward.burns@oracle.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt;&gt;&gt;&gt;&gt; On Mon, 26 Jul 2010 08:14:42 +0200, Martin Marinschek &lt;<a href="mailto:mmarinschek@apache.org">mmarinschek@apache.org</a>&gt; said:<br>
<br>
MM&gt; Hi guys,<br>
MM&gt; sorry, it took me a while to review the patch, but this is Leonardo´s<br>
MM&gt; suggestion for partial state saving in tables. He also included a test<br>
MM&gt; webapp, and a test for Mojarra.<br>
<br>
It&#39;s no problem.  I&#39;m not surprised it took so long.  For me, at least,<br>
this is a very complicated issue to understand.  At this point in the<br>
life of JSF, it&#39;s these kinds of issues that remain unsolved.<br>
<br>
Here is my response.<br>
<br>
<a href="https://javaserverfaces-spec-public.dev.java.net/nonav/issues/showattachment.cgi/268/message.txt" target="_blank">https://javaserverfaces-spec-public.dev.java.net/nonav/issues/showattachment.cgi/268/message.txt</a><br>

<br>
Included inline for convenience.<br>
<br>
I&#39;m now going to just apply Leonardo&#39;s patch and see what happens to our<br>
existing automated tests.<br>
<br></blockquote><div><br>Note by default this feature is not active, so I think to test it fully it is necessary to activate it setting<br>preserveRowComponentState to true.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

LU&gt; In theory, any solution to this issue must do something like this:<br>
<br>
LU&gt; - Save the &quot;initial state&quot; of all component children, excluding<br>
LU&gt; facets of nearest children (usually instances of UIColumn), after<br>
LU&gt; the component tree is build.<br>
<br>
This is just the normal mark initial state, right?<br>
<br></blockquote><div><br>Yes, but for UIData, it must save the initial state of all children in a structure, so<br>when setRowIndex() is called, it can restore the component state as it was before markInitialState().<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
LU&gt; - When setRowIndex method is called, it should save the &quot;partial&quot; or<br>
LU&gt; &quot;delta&quot; state of the current row somewhere, change the row, and<br>
LU&gt; finally restore the state using the &quot;initial state&quot; of the row and<br>
LU&gt; the delta saved, if any.<br>
<br>
Yes, this makes sense.<br>
<br>
LU&gt; Based on the previous ideas, the following (personal) conclusions<br>
LU&gt; arise:<br>
<br>
LU&gt; 1. Use a property to enable disable this behavior is preferred,<br>
LU&gt; because it is possible to have a non &quot;reliable&quot; model, or the user<br>
LU&gt; could have situations where it is not required to preserve the state<br>
LU&gt; per component. The patches adds a property called<br>
LU&gt; &quot;preserveRowComponentState&quot;.<br>
<br>
That&#39;s fine with me.<br>
<br>
LU&gt; 2. It is necessary to know &quot;when&quot; we can calculate the &quot;initial<br>
LU&gt; state&quot; of the rows: In the proposed patches, the idea is use<br>
LU&gt; UIData.markInitialState and check if we should save the &quot;initial&quot;<br>
LU&gt; state. To do that I&#39;m considering two options:<br>
<br>
LU&gt;    a. Move markInitialState calls, so they will be called after the<br>
LU&gt; component tree is built by facelets vdl. In this way we can ensure<br>
LU&gt; we are calling from parents to children, and we can call saveState<br>
LU&gt; directly on all children.<br>
<br>
LU&gt;    b. Do not move the calls, but take into consideration that some<br>
LU&gt; children could already be marked, so for those ones we need to call<br>
LU&gt; clearInitialState, saveState and then markInitialState.<br>
<br>
LU&gt;    Why two options?.<br>
<br>
LU&gt;   Some time ago, myfaces used a listener attached to<br>
LU&gt; PostAddToViewEvent for &quot;relocate&quot; components. In theory we have 4<br>
LU&gt; cases: h:outputScript, h:outputStylesheet, cc:insertChildren and<br>
LU&gt; cc:insertFacet.<br>
<br>
Mojarra still uses a listener for this.<br>
<br>
LU&gt; PostAddToViewEvent listener is used on<br>
LU&gt; h:outputScript and h:outputStylesheet by the spec, but it was<br>
LU&gt; necessary to use it on cc:insertChildren and cc:insertFacet, because<br>
LU&gt; there was a problem with nested composite components. But right now,<br>
LU&gt; after some discussions and new ideas provided, myfaces core 2.0.1<br>
LU&gt; has a algorithm that uses a variant of facelets template client api,<br>
LU&gt; so cc:insertChildren and cc:insertFacet does not use a<br>
LU&gt; PostAddToViewEvent listener anymore.<br>
<br>
Andy Schwartz suggested Mojarra move to using the template client<br>
approach for cc:insertChildren and cc:insertFacet in issue 1680 [1].  We<br>
opted for a simpler option to allow the Facelets tagHandler to correctly<br>
locate the relocated child in the postback case.  Therefore, I&#39;m very<br>
reluctant to adopt a fix to UIData state saving that will break our fix<br>
for 1680.<br>
<br></blockquote><div><br>In myfaces we did something similar, but after thinking more about it and take<br>into consideration the semantic of ui:composition, ui:define and ui:insert it<br>becomes necessary to change it. The way suggested by Andy is better, because<br>
it handle correctly interactions between nested composite components and <br>template tags (TemplateContext concept). I have some tests that shows it,<br> but I think it is worth to propose this change on mojarra.<br> </div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
LU&gt;   Allow component relocation using PostAddToViewEvent causes a lot<br>
LU&gt; of trouble. It is more, add/remove components &quot;programatically&quot;<br>
LU&gt; causes a lot of problems too (that&#39;s another discussion). Just one<br>
LU&gt; example: components relocated using cc:insertChildren or<br>
LU&gt; cc:insertFacet does not preserve state, because on each request, the<br>
LU&gt; components are relocated and the ones with the state are removed by<br>
LU&gt; facelets refresh algorithm, used by c:if tag.<br>
<br>
This problem with c:if has been fixed with in issue 1527 [2].  If you<br>
find that the solution in that issue is faulty, please let the Mojarra<br>
team know.<br>
<br></blockquote><div>Ok, I&#39;ll take a look to this point.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
LU&gt;   The option (a) consider that if PostAddToViewEvent listeners are<br>
LU&gt; used to relocate components, only it is safe to save the &quot;initial<br>
LU&gt; state&quot; after the tree is completely built, so we require a fix for<br>
LU&gt; markInitialState() and some way to indicate we are calling this<br>
LU&gt; method from the specified location.<br>
<br>
This sounds reasonable.<br>
<br>
LU&gt;   The option (b) consider that PostAddToViewEvent should not be used<br>
LU&gt; to relocate components. If components are relocated, the destiny<br>
LU&gt; should be outside a UIData instance (h:outputScript and<br>
LU&gt; h:outputStylesheet usually relocates to &quot;head&quot; or &quot;body&quot;), otherwise<br>
LU&gt; the &quot;initial state&quot; will be invalid. Since latest myfaces code<br>
LU&gt; allows this, the option (b) will work there. Anyway, I provide a<br>
LU&gt; patch for mojarra, so people can see how should looks like, but to<br>
LU&gt; make it work requires some big changes.<br>
<br>
Yes, it would.  And we&#39;re not in a position to want to make big changes<br>
now.<br>
<br>
LU&gt; 3. The &quot;delta&quot; state of each row should be saved / restored<br>
LU&gt; somewhere with the page: In the proposed patch the deltas are saved<br>
LU&gt; with the state of UIData.<br>
<br>
That is a reasonable place to save it.<br>
<br>
LU&gt; 4. A way to save/restore transient variables like UIForm submitted<br>
LU&gt; should be provided. The proposed patch includes two new interfaces<br>
LU&gt; called TransientStateHelper and TransientStateHolder to deal with<br>
LU&gt; this stuff (save/restore and manipulate them). As a curious fact,<br>
LU&gt; some days ago, a non very clean solution was applied on<br>
LU&gt; &quot;TRINIDAD-1849 subform in table not working&quot; that could be solved<br>
LU&gt; better with interfaces like the ones proposed here.<br>
<br>
Ok, this sounds good too.  I&#39;m going to try to understand the patch now,<br>
but I think you&#39;ve done some great work.  I just hope that it can be<br>
made to apply to Mojarra as well as your MyFaces.<br>
<br></blockquote><div><br>Thanks Ed for take a look to this issue.<br><br>best regards,<br><br>Leonardo Uribe<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

[1] <a href="https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1680" target="_blank">https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1680</a><br>
<br>
[2] <a href="https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1527" target="_blank">https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1527</a><br>
<br>
<br>
Ed<br>
<font color="#888888"><br>
--<br>
| <a href="mailto:edward.burns@oracle.com">edward.burns@oracle.com</a> | office: +1 407 458 0017<br>
| homepage:               | <a href="http://ridingthecrest.com/" target="_blank">http://ridingthecrest.com/</a><br>
| 03 work days until JSF 2.1 Milestone 2<br>
</font></blockquote></div><br>