Reputation: 1071
The following snippet works:
<h:form id="form1">
<h:inputHidden value="#{bean.field1}" id="field1"/>
<h:inputHidden value="#{bean.field2}" id="field2"/>
<h:inputHidden value="#{bean.field3}" id="field3"/>
<h:inputHidden value="#{bean.field4}" id="field4"/>
<h:inputHidden value="#{bean.field5}" id="field5"/>
<h:inputHidden value="#{bean.field6}" id="field6"/>
<h:inputHidden value="#{bean.field7}" id="field7"/>
<h:inputHidden value="#{bean.field8}" id="field8"/>
<h:inputHidden value="#{bean.field9}" id="field9"/>
<p:remoteCommand name="loadRecord" actionListener="#{bean.loadRecord}"
process="@this"
update="field1 field2 field3 field4 field5 field6 field7 field8 field9" />
</h:form>
The problem is that when the number of fields to update is large (I have another page with 40 fields) it becomes unmaintainable.
I tried to use instead
<p:remoteCommand name="loadRecord" actionListener="#{bean.loadRecord}"
process="@this" update="@form" />
but the fields are not updated. Any ideas?
UPDATE:
This problem is not restricted to hidden fields, it seems to apply to any input field for example to
<h:inputText id="name" value="#{bean.name}" />
Upvotes: 0
Views: 2788
Reputation: 4238
You can wrap your fields (if they are grouped together) in a Naming Container. Then you only have to update the naming container and all it's content will be updated as well. Your h:form
is already a NamingContainer, but if you do not want to update your whole form you can try this:
<p:outputPanel id="myContainer">
<h:inputHidden value="#{bean.field1}" id="field1"/>
<h:inputHidden value="#{bean.field2}" id="field2"/>
<h:inputHidden value="#{bean.field3}" id="field3"/>
<h:inputHidden value="#{bean.field4}" id="field4"/>
...
</p:outputPanel>
<p:remoteCommand name="loadRecord" actionListener="#{bean.loadRecord}"
process="@this"
update="myContainer" />
Upvotes: 1
Reputation: 333
You should use the id of the form you want to update. In your case update="form1"
Upvotes: -1