Bug: Partial updates fail by reason of multiply CDATA

UI Components for JSF
User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

11 Mar 2010, 15:00

Hi Cagatay,

I don't know why, but partial update has sometimes no effect, nothing appears although partialResponse XML arrives browser. An example with a text inside of partial updated area

Code: Select all

<h:outputText value="Language: English [UK]"/>
This causes the following response (I have more stuff around)

Code: Select all

<partialResponse><components><component><id>mainForm_pt_section2_displayNameDescriptionList</id><output><![CDATA[<div id="mainForm_pt_section2_displayNameDescriptionList"><div class="displayNameDescriptionHeader">Language: English [UK]]]><![CDATA[<span id="mainForm_pt_section2_j_idt126_0_j_idt130"><a href="javascript:void(0);" class="deleteLink" onclick="PrimeFaces.ajax.AjaxRequest('/icManagement/views/main.jsf',{formId:'mainForm',async:true,global:true},{'mainForm_pt_section2_j_idt126_0_j_idt130_submit':'true','primefacesPartialUpdate':'mainForm_pt_section2_displayNameDescriptionList','primefacesPartialProcess':'mainForm_pt_section2_displayNameDescriptionList'});return false;">Delete</a></span></div><table class="displayNameDescriptionBody">
<tbody>
<tr>
<td class="panelsGridLabel"><label>
Display name: </label></td>
<td class="panelsGridValue"><input id="mainForm_pt_section2_j_idt126_0_propTemplateDisplayName" type="text" name="mainForm_pt_section2_j_idt126_0_propTemplateDisplayName" value="" /></td>
<td class="panelsGridLabel"><label>
Description: </label></td>
<td class="panelsGridValue"><textarea id="mainForm_pt_section2_j_idt126_0_propTemplateDescription" name="mainForm_pt_section2_j_idt126_0_propTemplateDescription" rows="2"></textarea></td>
</tr>
</tbody>
</table>
</div>]]></output></component></components><state><![CDATA[<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="7905747163784970717:-3619478966589138506" autocomplete="off" />]]></state><callbackParams><callbackParam>{"isValid":true}</callbackParam></callbackParams></partialResponse>
In this case doesn't appears anything. If I change the text to

Code: Select all

<h:outputText value="Language: English [UK]" escape="false"/>
with escape="false" then everything works fine! Without brackets [ and ] it works fine as well. I quess, this strange behavior occurs by reason of brackets. If we look response we see <![CDATA[ .... Language: English [UK]]]>. The question is why? The output is located within CDATA section, but nothing can be rendered.

Do you have an idea?
Last edited by Oleg on 24 May 2010, 09:33, edited 2 times in total.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

11 Mar 2010, 16:19

Interesting. With escape="false" (working version) I have

Code: Select all

<partialResponse><components><component><id>mainForm_pt_section2_displayNameDescriptionList</id><output><![CDATA[<div id="mainForm_pt_section2_displayNameDescriptionList"><div class="displayNameDescriptionHeader">Language: English [UK]<span id="mainForm_pt_section2_j_idt126_0_j_idt130"><a href="javascript:void(0);" class="deleteLink" onclick="PrimeFaces.ajax.AjaxRequest('/icManagement/views/main.jsf',{formId:'mainForm',async:true,global:true},{'mainForm_pt_section2_j_idt126_0_j_idt130_submit':'true','primefacesPartialUpdate':'mainForm_pt_section2_displayNameDescriptionList','primefacesPartialProcess':'mainForm_pt_section2_displayNameDescriptionList'});return false;">Delete</a></span></div><table class="displayNameDescriptionBody">
.................
</div>]]></output></component></components><state><![CDATA[<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-766650032472478183:-1440989896510561860" autocomplete="off" />]]></state><callbackParams><callbackParam>{"isValid":true}</callbackParam></callbackParams></partialResponse>
You see, the sequence Language: English [UK] doesn't break CDATA. Look difference

Code: Select all

... Language: English [UK]]]><![CDATA[<span ...
and

Code: Select all

... Language: English [UK]<span ...
I think, we have to look deeper into the PrimeFacesPhaseListener.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

11 Mar 2010, 17:17

I'm very confused, PrimeFacesPhaseListener looks okey for me - start CDATA, encodeAll, end CDATA. On the other hand these CDATAs in the middle could be not generated by h:outputText. Any ideas?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Mar 2010, 18:24

CDATA handling is a responsibility of JSF implementation actually, we had a discussion about CDATA handling recently in JSF EG mailing list. The answer is not in PrimeFacesPhaseListener but in how JSF impl CDATA, for example MyFaces doesn't care about CDATA so it was causing problems.

I'm not really sure what's going on here as well, need to look in Mojarra source. But I think escape="false" is a good workaround.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

11 Mar 2010, 23:04

cagatay.civici wrote:CDATA handling is a responsibility of JSF implementation actually, we had a discussion about CDATA handling recently in JSF EG mailing list. The answer is not in PrimeFacesPhaseListener but in how JSF impl CDATA, for example MyFaces doesn't care about CDATA so it was causing problems.

I'm not really sure what's going on here as well, need to look in Mojarra source. But I think escape="false" is a good workaround.
Yes and no. :-) You parse your response self. If you say it depends on implementation then you can not trust rendered section between PrimeFaces start /end CDATA. You see, mojarra closes your opened CDATA within "output" tag and begins a new CDATA: <![CDATA[.......]]><![CDATA[......]]. They may do it even right. That means, PrimeFaces.ajax.AjaxResponse (core.js) should iterate over CDATA childNodes and merge their content. So, instead of

Code: Select all

output = components[i].childNodes[1].firstChild.data;
the right code would be

Code: Select all

		output = "";
		var kids = components[i].childNodes[1].childNodes;
		for (i = 0; i<kids.length; i++) {
			output = output + kids[i].firstChild.data;
		}
I think, it's a PrimeFaces responsibility. It's very strange when the single ] sign somewhere on the updated area prohibits the entire displaying. So, I put ] and no partial update works. Hmm... My code with iteration is always working independent of JSF implementation. ;)
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

24 May 2010, 09:29

Hello Cagatay,

I encounter again and again this issue. Now with datatable. I repeat the problem once again: PrimeFaces partial updates fail if we have a sign ] (close bracket) in the output. In case of datatable we have then more CDATA's which can not be parsed. Example: putting the text "Test [en]" into a column cell breaks the entire table (nothing is rendered). We have

Code: Select all

<data-response><table><![CDATA[<table ... </td><td>Test [en]]]><![CDATA[</td><td> ... </table>]]></table><row-count> ... </row-count><state> ... </state></data-response>
PrimeFaces has problem with more than one CDATAs inside of data-response. A solution was already provided in this post. What do you think Cagatay?

This is a stopper for us because our customers input very often a text with language in brackets. I have created an issue ticket http://code.google.com/p/primefaces/iss ... ail?id=827

Thanks.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2010, 09:42

JSF2's ResponseWriter has startCDATA endCDATA api which PrimeFaces hasn't taken advantage yet because of a MyFaces issue, now MyFaces 2 is out, we can migrate to that for JSF 2.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

24 May 2010, 09:45

cagatay.civici wrote:JSF2's ResponseWriter has startCDATA endCDATA api which PrimeFaces hasn't taken advantage yet because of a MyFaces issue, now MyFaces 2 is out, we can migrate to that for JSF 2.
Super! Good news. It would be interesting what we have in the output after migration. :-)
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2010, 20:21

Can we replicate this at the simplest ppr example?

http://www.primefaces.org:8080/prime-sh ... Update.jsf

For example if I type sth [en] it works. What to enter to make it fail? Or is it just a datatable related issue?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2010, 20:33

I've migrated to standard CDATA handling API of JSF 2.0, datatable is migrated as well to this now.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 42 guests