So, I have a datatable like this:
<p:dataTable var="object" value="#{objectBean.objects}"
paginator="true" rows="10" editable="true" id="tableObjects"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" style="border: 0px">
<p:column sortBy="#{object.etc}">
..
</p:column>
...
<p:column sortBy="#{object.someValue}" id="sucessoColumn"
headerText="Value">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{object.someValue}" />
</f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{object.someValue}" effect="fade"
id="opt">
...
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column id="bColumn" headerText="Options">
<p:rowEditor />
</p:column>
<p:ajax event="rowEdit" listener="#{objectBean.update}"></p:ajax>
</p:dataTable>
On a page that receives a parameter like this:
<f:metadata>
<f:viewParam name="id" value="#{objectBean.object}"
converter="#{objectConverter}" converterMessage="Converter error !"
required="true" requiredMessage="Missing object !" />
</f:metadata>
When the page is loaded, there is no problem at all, and everything works fine. But when I click on next page or try editing the row, then the “required message” from the viewparam appears. It looks like that the param disappears when anything on the datatable changes.
Any ideas ?
Thank you.
The problem was with the scope of the Bean we were using.
It seems that, every time that the state of the datatable changes, it makes another request for the bean. If it was request scoped, the parameter was only available for the first request.
Changing to ViewScope solved half of the problem. The datatable worked as it should, but the message still appears. Taking of the “required” and “requiredMessage” attributes solved the last part of the problem and everything worked like a charm.