0
votes

I'm trying to use the validateMultiple to validate two fields. However, when validation fails it clears out both the fields:

     <p:inputText value="#{bmiBean.height}" required="true" id="height" style="width:40px;">
                <p:ajax update="bmiPanel" process="bmiValidator" />
    </p:inputText>
    <p:inputText value="#{bmiCalculatorBean.weight}" required="true" id="weight" >
        <p:ajax update="bmiPanel" process="bmiValidator" />
        <f:convertNumber pattern="0" />
     </p:inputText>


    <o:validateMultiple id="bmiValidator" components="weight height" validator="#{bmiBean.validate}" message="Your BMI is not high enough"
                />


    <p:message for="bmiValidator" id="msgBmiValidatorQuestion" />

Ideally I would like the height and weight properties to be set so when the user refreshes the page they are still present.

1

1 Answers

0
votes

You forgot to process the inputs themselves.

<p:ajax update="bmiPanel" process="bmiValidator" />

Alter it to include the client IDs of the inputs as well. I'll assume that bmiPanel already covers them:

<p:ajax update="bmiPanel" process="bmiPanel" />

See also: