Partial Rendering will only work with @form ?

UI Components for JSF
Post Reply
moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

10 May 2011, 06:47

Hello,

I have a strange situation where using @parent, or even explicit id-s dont work in the update attribute. But @form works fine.

I've made a very simple test case, that includes a simple grid whose behaviour is like this :
  • * Every record inside the grid has a modify button
    * After the modify button is clicked, it'll modify the server data, and the button will be gone, since it'll be only rendered if the record has NOT been modified.
The modify button is like this :

Code: Select all

<!-- this works, since it's using @form in the update attribute -->
<p:column>
	<p:commandLink
		value="modify record" 
		process="@this" 
		action="#{testUserBean.modifyRecord(user)}"
		update="@form"
		rendered="#{not testUserBean.isRecordModified(user)}" />
</p:column>
Notice that the update attribute makes use of @form which makes it work: when the modify button is clicked, it rerenders and disappears.

Substitute it with @this or @parent or the id of the grid, then it will NOT work. For me it's very logical to use the id of the grid in the update attribute, since i would like to refresh the grid after clicking on the buttton.
I tried making use of

Code: Select all

rowIndexVar="rowIndex"
and

Code: Select all

myGridId:#{rowIndex}:link
, but still aint working.

Code: Select all

<!-- this does not work -->
<p:column>
	<p:commandLink id="link"
		value="modify record" 
		process="@this" 
		action="#{testUserBean.modifyRecord(user)}"
		update="tblUser"
		rendered="#{not testUserBean.isRecordModified(user)}" />
</p:column>
Here are the resources for this simple example : Please share your ideas. Is this a bug or i did something wrong ?

Im using tomcat 7, and these are my dependencies :

Code: Select all

    <dependency>
    	<groupId>org.primefaces</groupId>
    	<artifactId>primefaces</artifactId>
    	<version>2.2.1</version>
    </dependency>
    <dependency>
    	<groupId>com.sun.faces</groupId>
    	<artifactId>jsf-api</artifactId>
    	<version>2.0.4-b09</version>
    	<scope>compile</scope>
    </dependency>
    <dependency>
    	<groupId>com.sun.faces</groupId>
    	<artifactId>jsf-impl</artifactId>
    	<version>2.0.4-b09</version>
    	<scope>compile</scope>
    </dependency>
Tried out 3.0.M1, but still have the same behaviour

Thank you !

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

10 May 2011, 11:47

Hi

Code: Select all

I have a strange situation where using @parent, or even explicit id-s dont work in the update attribute. But @form works fine.
I agree. We have faced exactly this problem with @parent too. With @form everything works fine. In my case @parent was in "process", but the action was not fired. Can anybody confirm it too?
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

porthos
Posts: 122
Joined: 09 May 2011, 03:17

12 May 2011, 00:13

Haven't tried all of the options you mention. But explicit ids definitely don't work for me inside a dataTable using PF 2.2. They just render to the same string, instead of a resolved id.

Things like the following do work for me though, if you want to avoid updating the entire form:

Code: Select all

 update="#{component.parent.parent.clientId}"
Feels like a bug to me.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

12 May 2011, 12:59

I've just updated my test using :

Code: Select all

    <p:commandLink
    	value="modify record" 
    	process="@this" 
    	action="#{testUserBean.modifyRecord(user)}"
    	update=":mainForm:tblUser"
    	rendered="#{not testUserBean.isRecordModified(user)}" />
Notice i used the `:mainForm:tblUser`, and i've tried the other options and still failed :
  • 1. :mainForm:tblUser:
    2. :tblUser (when i dont define the form name)
    3. :mainForm:tblUser:#{rowIndex}:linkId
But 1 thing i notice is,nNo matter what i choosed for the update, the update always ends up as **tblUser:0**

Code: Select all

    <a onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/test.xhtml',
    {formId:'mainForm',async:false,global:true,source:'tblUser:0:j_idt33',
      process:'tblUser:0:j_idt33',
      update:'tblUser:0'
    });" href="javascript:void(0);" id="tblUser:0:j_idt33">modify record</a>
I tried modifying tblUser:0 on the fly using firebug to just tblUser, the partial rendering on the grid works fine.

Im beginning to think that this is a bug when trying to update a grid from inside a grid record.

porthos
Posts: 122
Joined: 09 May 2011, 03:17

12 May 2011, 22:18

Not just the grid, try specifying any random component by id, it won't work. Only @form and EL expressions seem to work for me.

But I'm not getting exactly the same result. With PF 2.2 I just get the string from p:commandButton's update unaltered. In your case with PF 3 it seems to be returning id of the table row.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

13 May 2011, 06:02

First time for me ever to create an issue ticket for primefaces ..

http://code.google.com/p/primefaces/iss ... il?id=2035

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

29 Jun 2011, 05:34

The issue had a reply : This is a core JSF issue, you need to update a wrapper of a data component.

Im very happy that there seems to be a solution for this problem,
but i dont really understand how to implement it.

I would like to refresh the grid or perhaps the row of the grid that is being 'actioned',
how do i provide a wrapper for this partial refresh to work ?

Please share your thoughts, thank you !

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

29 Jun 2011, 08:29

This is more like a mojarra issue, it should work fine with myfaces without a wrapper. Workaround is to put a wrapper.

Code: Select all

<h:form id="frm">
   <p:outputPanel id="wrapper">
       <p:dataTable id="tbl">
       //...
           <p:commandButton update=":frm:wrapper" />
       //...
       <p:dataTable>
   <p:outputPanel>
</h:form>

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

08 Jul 2011, 12:00

I love you ! Thanks, works like magic !

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests