It is not well designed but yet a valid component (as I said the issue originated from an issue I got for myfaces and I gave also the root node recommendation), as I said both approaches are broken, but an error definitely has to be emitted in this case, I will do that on the client side and warn the author of the component that it has to habe a root node with the client id!<br>
After all we have the error API in place, why not use it a little bit more :-)<br>Also the spec clearly does just say that the code part with the client id has to be replaced with the content of the CDATA block afair!<br>
<br>The main issue I have with the old approach compared to mojarras and our newer approach<br>is, that if you just update the client id with the code junk coming in from the client without taking the clientid itself into consideration you end up with a broken dom tree, aka a dom tree with multiple nodes having the same id, hence the behavior definitely is more broken in the old way than in the new way.<br>
<br>The probably cleanest solution probably would be to stop the dom tree update (and dont update) or leave the affected part blank, or with something which signals that the area could not be updated due to the problem and raise the error.<br>
<br>As for exposing the PartialResponseWriter API to the components in myfaces only, this does not make sense too much it would bind the components to the impl and I am not sure what the status about the approach is which hopefully will go into 2.1. This needs to be fixed on the API side and should have been before 2.0 went into production but that did not happen, probably because it was too late when this issue was discovered.<br>
<br><br>Werner<br><br><br><div class="gmail_quote">On Wed, Apr 7, 2010 at 12:28 PM, Ganesh <span dir="ltr">&lt;<a href="mailto:ganesh@j4fry.org">ganesh@j4fry.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
I agree with Alexander. The component you posted is not well designed. As Alexander pointed out: What would getClientId() return for this component? I also agree with Alexanders solution: enclose the components reposne with a div that carries a proper clientId.<br>

<br>
It&#39;s an obvious characteristic of JSF AJAX to require having one HMTL element corresponding with one JSF component to be able to replace it via AJAX. Trying to craft a sophisticated solution for the cornercase of a badly designed component leads to a highly complicated specification enhancement that only makes sense to very few experts.<br>

<br>
Best regards,<br>
Ganesh<br>
<br>
Martin Marinschek schrieb:<div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Werner,<br>
<br>
no. Don&#39;t follow any broken approach - emit an error saying that this<br>
is not possible. Then the component author will know. Mojarra should<br>
do the same.<br>
<br>
I agree that the API should be more open than. Can we expose this API<br>
unilaterally at least in MyFaces?<br>
<br>
best regards,<br>
<br>
Martin<br>
<br>
On 4/7/10, Werner Punz &lt;<a href="mailto:werner.punz@gmail.com" target="_blank">werner.punz@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The problem here is either behavior is wrong (not sure which is wronger), in<br>
the end the only real fix is to expose the full partialresponse writer API<br>
to the component author to give him full access on how his subpart on the<br>
page gets updated.<br>
<br>
This road currently is blocked simply by enforcing an open update tag on the<br>
components from the rendering lifecycle!<br>
<br>
The workaround is to make the component authors aware that for the PPR case<br>
within a component they always should make a root node which has the<br>
identifier of ClientId and embed their own rendering into this root node<br>
(div, span, whatever)<br>
<br>
So if I follow a broken approach I personally prefer to use the one which is<br>
consistent over all two implementations.<br>
<br>
In the end the only fix I know which makes sense to this problem is to add a<br>
marker interface to the spec<br>
something like PPRAware and a separate component renderer method, renderPPR<br>
and then adding placeholders for the component while the update tag is open,<br>
defer the rendering of the PPRAware component to the stage when update is<br>
closed<br>
and then render those deferred components by giving them control over the<br>
update, insert etc... possibilities wie theoretically have in the API and<br>
practically can only use outside of the render cycle :-(<br>
<br>
<br>
<br>
<br>
On Wed, Apr 7, 2010 at 9:26 AM, Martin Marinschek<br>
&lt;<a href="mailto:mmarinschek@apache.org" target="_blank">mmarinschek@apache.org</a>&gt;wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi guys,<br>
<br>
is it really useful to follow Mojarra&#39;s behaviour here? I think it<br>
might be a little better to have a wandering div (and see that<br>
something is wrong) than just ignoring the second div and with this<br>
let the developer in the believe that everything is alright, which it<br>
really isn&#39;t.<br>
<br>
best regards,<br>
<br>
Martin<br>
<br>
On 4/7/10, Werner Punz &lt;<a href="mailto:werner.punz@gmail.com" target="_blank">werner.punz@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Yes that is what I was basically posting as workaround to the issue I<br>
</blockquote>
got,<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
nevertheless I now coded Mojarras behavior into MyFaces, just to be<br>
consistent here.<br>
(With the exception that I also fixed it on the IE side as Mojarra<br>
</blockquote>
behaves<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
for<br>
more compliant  browsers to have the same behavior over all browsers)<br>
<br>
I do not expect any component author really doing it differently than<br>
you<br>
said, Alex, but in the end to really resolve the problem we probably<br>
have<br>
</blockquote>
to<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
resolve the enforced update issue in the long run so that the<br>
PartialResponseWriter API can be used in its full extent and glory by<br>
the<br>
component authors instead of being shoehorned into an already open<br>
update<br>
tag!<br>
<br>
Werner<br>
<br>
<br>
On Wed, Apr 7, 2010 at 12:05 AM, Alexander Smirnov<br>
&lt;<a href="mailto:asmirnov@exadel.com" target="_blank">asmirnov@exadel.com</a>&gt;wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You have to keep in mind that JSF Ajax updates component content, not<br>
the Html elements. Therefore, any component have to has enclosing Html<br>
element ( &lt;div&gt; , &lt;span&gt; whatever else ) with id attribute generated as<br>
the component clientId to be compatible with Ajax. In your case, you<br>
have to create placeholder element ( probably &lt;div&gt; ) that encapsulates<br>
both of your elements.<br>
<br>
On 04/06/2010 09:42 AM, Werner Punz wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello everyone, I ran into an issue regarding the update, which is<br>
closely related to a behavior jsf2 exposes regarding component<br>
</blockquote></blockquote></blockquote>
rendering<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
in the update cycle.<br>
<br>
The main issue is following: If we have a component which we trigger<br>
with following code:<br>
<br>
 &lt;myComp:javascriptTestComponent<br>
id=&quot;myTestComponent&quot;&gt;&lt;/grv:javascriptTestComponent&gt;<br>
                &lt;a href=&quot;#&quot; name=&quot;mego3&quot;<br>
<br>
onclick=&quot;jsf.ajax.request(this,event,{execute:&#39;myTestComponent&#39;,<br>
render:&#39;myTestComponent&#39;}); return false;&quot;&gt;submit<br>
                    me&lt;/a&gt;<br>
<br>
and the component itself renders following in its renderer:<br>
<br>
        ResponseWriter writer = context.getResponseWriter();<br>
        writer.startElement(DIV, component);<br>
        writer.writeAttribute(ID,component.getClientId(context), null<br>
</blockquote></blockquote></blockquote>
);<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
        writer.write(&quot;hello world&quot;+Math.random());<br>
        writer.endElement(DIV);<br>
<br>
        writer = context.getResponseWriter();<br>
        writer.startElement(DIV, component);<br>
<br>
writer.writeAttribute(ID,component.getClientId(context)+&quot;:_second&quot;,<br>
</blockquote></blockquote></blockquote>
null<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

);<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
        writer.write(&quot;hello world&quot;+Math.random());<br>
        writer.endElement(DIV);<br>
<br>
<br>
the resulting ppr response now looks like following:<br>
<br>
|&lt;update id=&quot;myTestComponent&quot;&gt;<br>
<br>
&lt;![CDATA||[&lt;div id=&quot;myTestComponent&quot;&gt;hello<br>
</blockquote></blockquote></blockquote>
world0.8619488403376933&lt;/div&gt;<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
&lt;div id=&quot;myTestComponent:_second&quot;&gt;hello||<br>
</blockquote>
world0.25176272071402683&lt;/div&gt;]]&gt;<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
&lt;/update&gt;...|<br>
<br>
Now the problem is, since the update part of the response is already<br>
opened the component author cannot really influence the response<br>
rendering in any meaningful way (the correct solution would be to<br>
</blockquote></blockquote></blockquote>
issue<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
two update commands here)<br>
Now the javascript has to react on the client side to resolve that<br>
situation.<br>
<br>
Now MyFaces just replaced the original<br>
<br>
|myTestComponent|<br>
<br>
with the update code and hence the result was a div wandering down<br>
</blockquote></blockquote></blockquote>
(aka<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
wrong update)<br>
<br>
hello world0.48748236239247755<br>
hello world0.6020541783857698<br>
hello world0.7181842402648805<br>
hello world0.2803064696069696<br>
(after a handful of requests, with the lowest line being the first<br>
second div being dran)<br>
<br>
now due to being incorrect a user gave me rightfully a bug issue. I<br>
</blockquote></blockquote></blockquote>
dug<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
deeper and ran the same example<br>
against Mojarra, now Mojarra does cherry pick the delivered first div<br>
and replaces the original div, and omits the second one.<br>
The Problem is Mojarra just does it for newer browsers, it does the<br>
</blockquote></blockquote></blockquote>
same<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
just updating the  original element with the replacement code<br>
(and hence producing a wandering div) for IE6+7-<br>
<br>
My question is, first, how to handle that problem correctly.<br>
Secondly,<br>
is this even a problem for us or more one for the component author?<br>
In the end the main problem would not exist if they ajax api could be<br>
used on the component side properly without being enforced already<br>
</blockquote></blockquote></blockquote>
into<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
an update (or to allow nested updates, inserts within an update)<br>
<br>
<br>
Werner<br>
<br>
</blockquote></blockquote></blockquote>
<br>
--<br>
<br>
<a href="http://www.irian.at" target="_blank">http://www.irian.at</a><br>
<br>
Your JSF powerhouse -<br>
JSF Consulting, Development and<br>
Courses in English and German<br>
<br>
Professional Support for Apache MyFaces<br>
<br>
</blockquote></blockquote>
<br>
<br>
</blockquote>
<br>
-- <br></div></div>
&quot;There are two kinds of people in the world, those who believe there are two kinds of people and those who don&#39;t.&quot;<br>
— Robert Benchley<br>
</blockquote></div><br>