I have a strange situation where using the @parent attribute or even explicit id-s does not work in the update attribute. But @form works fine.
I made a very simple test case that includes a simple grid, whose behavior is as follows:
- Each entry inside the grid has a change button.
- After clicking the βChangeβ button, it will change the server data, and the button will disappear, because it will only be displayed if the record has NOT been changed.
The change button looks like this:
<p:column> <p:commandLink value="modify record" process="@this" action="#{testUserBean.modifyRecord(user)}" update="@form" rendered="#{not testUserBean.isRecordModified(user)}" /> </p:column>
Note that the update attribute uses @form, which makes it work: when you click the change button, it is restored and disappears.
Substitute it with @this or @parent or the grid id, then it will NOT work. It is very logical for me to use the grid identifier in the update attribute, since I would like to update the grid after clicking on the button. I tried using rowIndexVar="rowIndex" and myGridId:#{rowIndex}:link , but still not working.
<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:
Im using tomcat 7 and these are my dependencies:
<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>
I also tried the 3.0.M1 formats, but it also got the same behavior.
Share your ideas. Is this a mistake, or did I do something wrong?
UPDATE
Hello,
I just finished testing, but still fail.
Test 1 (using update=":gridRPBDetails" ):
JSF file:
<p:commandLink id="undoLink" value="Undo" process="@this" action="#{tInputBean.actionUndoRemoveRecord(rpbDetail)}" update=":gridRPBDetails" rendered="#{tInputBean.isRemoveRecord(rpbDetail)}" title="Batalkan buang data" />
Generated xhtml:
<a title="Batalkan buang data" onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/TInput.xhtml', {formId:'j_idt38',async:false,global:true,source:'gridRPBDetails:0:undoLink', process:'gridRPBDetails:0:undoLink',update:':gridRPBDetails'});" href="javascript:void(0);" id="gridRPBDetails:0:undoLink">Undo</a>
Test 2 (using update=":gridRPBDetails:#{rowIndex}:undoLink" ):
JSF file:
<p:commandLink id="undoLink" value="Undo" process="@this" action="#{tInputBean.actionUndoRemoveRecord(rpbDetail)}" update=":gridRPBDetails:#{rowIndex}:undoLink" rendered="#{tInputBean.isRemoveRecord(rpbDetail)}" title="Batalkan buang data" />
Generated xhtml:
<a title="Batalkan buang data" onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/TInput.xhtml', {formId:'j_idt38',async:false,global:true,source:'gridRPBDetails:0:undoLink', process:'gridRPBDetails:0:undoLink',update:':gridRPBDetails:0:undoLink'});" href="javascript:void(0);" id="gridRPBDetails:0:undoLink">Undo</a>
Both tests still do not work with the cancel button, cannot update the grid record or even the grid itself.
UPDATE
I just updated my test using:
<p:commandLink value="modify record" process="@this" action="#{testUserBean.modifyRecord(user)}" update=":mainForm:tblUser" rendered="#{not testUserBean.isRecordModified(user)}" />
Notice that I used :mainForm:tblUser , and I tried other options and still failed:
- : MainForm: tblUser:
- : tblUser (when I don't define the form name)
- : MainForm: tblUser: # {RowIndex}: LinkId
But one thing that I notice is that I chose to update, the update always ends as tblUser: 0
<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 only for tblUser , partial rendering on the grid works fine.
Im starting to think that this is a mistake when trying to update the grid from inside the grid record.