本文介绍了在MAF page中做验证
在表单提交之前,通常要对表单进行验证,跟JS表单验证是一个道理。
<amx:validationGroup id="vg1">
<amx:panelFormLayout id="pfl1">
<amx:inputText value="#{bindings.country_id.inputValue}" label="#{bindings.country_id.hints.label}" id="it3" required="true" showRequired="true" />
<amx:inputText value="#{bindings.country_name.inputValue}" label="#{bindings.country_name.hints.label}" id="it2" required="true" showRequired="true" />
</amx:panelFormLayout>
</amx:validationGroup>
<amx:commandButton actionListener="#{bindings.updateLocRecord.execute}" text="Update" disabled="#{!bindings.updateLocRecord.enabled}" id="cb3">
<amx:validationBehavior id="vb1" group="vg1"/>
</amx:commandButton>
加上如上的验证后,可以在提交之前做非空的验证。