I’m using primefaces 2.2.1
and I want set f:validatorLength to one row in datatable with many rows with p:cellEditor.
<c:set var="flag" value="#{item.key eq 'someKey'}" />
<p:column headerText="header">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.value}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.value}" style="width:100%" >
<f:validateLength maximum="4" disabled="#{flag}"/>
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
And when flag is true for chosen inputText with appropriate key, then validator turn on for all inputTexts. And when flag is false – validator turn on for all inputTexts. But I want set validator to some inputTexts and so on.
Any ideas?
Thanks.
This is a known problem. The attributes of
<f:validateXxx>tags are evaluated during view build time. So they can’t depend on a variable which is only available during view render time.This is basically the same problem as outlined and answered in detail here: How to set converter properties for each row of a datatable?
In your particular case, apart from homegrowing a validator yourself which programmatically evaluates
#{item}inside thevalidate()method, you could use OmniFaces<o:validator>which enables render-time evaluation of all attributes.