0
votes

can someone explain why following minimal example won't evaluate the required element? Or is it the "wrong" way and there is a better one I don't know.

I'm aware that my question is similiar to this question: Primefaces cellEditor required inputText. For me it seems that the solution is more of a workaround than a valid way to cope with this problem. So yeah any ideas how to deal with this?

Code:

 <p:dataTable id="ruleTableID" var="rule" value="#{rC.rules}" widgetVar="rowsTable" 
     rows="20" editable="#{rC.editable}" 
     editMode="cell" paginator="true" 
     paginatorPosition="bottom" paginatorTemplate="{Save}"
     emptyMessage="#{t['rule.empty']}">
  <p:ajax event="cellEdit" update=":newRules:messages, :newRules:" />
  <p:column headerText="#{t['policy.registerNumber']}">
    <p:cellEditor>
      <f:facet name="input">
        <p:inputText styleClass="ruleInputText" value="#{rule.registerNr}" required="true" maxlength="4">
          <f:validateLength minimum="4" />
          <f:validateRegex pattern="([A-Z\d]{4})" />
          <p:clientValidator/>
        </p:inputText>
      </f:facet>
      <f:facet name="output">
        <h:outputText value="#{rule.registerNr}" />
      </f:facet>
    </p:cellEditor>
  </p:column>

  <f:facet name="{Save}">
    <p:commandButton id="saveButton" value="#{t['button.save']}" action="#{rC.saveRules}" update=":newRules" rendered="#{rC.isAllValueSet}" />
   </f:facet>

</p:dataTable>
1
I don't know if it's causing the problem, but your regex looks wrong. You've specified a minimum length of 4, but your regex accepts only a single character (ref). - DavidS
Not the problem, but I changed that, thanks ^^ - theFan

1 Answers

0
votes

If you are using client side validation you have to add the attributes ajax="false" and validateClient="true" to your commandButton

You can see a example here: http://www.primefaces.org/showcase/ui/csv/event.xhtml