我有一个包含多个字段的表单,并且有一个包含两个必填字段和搜索按钮的块。 我想要的是,当我点击搜索按钮时,我想忽略表单验证,并且两个字段的值在bean中设置,但这不会发生。 我应该如何应用这些值?单击特定按钮并设置特定值时跳过验证
编辑:我在视图中有更多必填字段,在这种情况下,我想忽略。
<p:inputMask id="field1" mask="9999" styleClass="marginLeft input smaller"
requiredMessage="#{label.msg_requiredFields}"
required="true" value="#{cc.attrs.cena.field.cp4Offline}"/>
<p:inputMask id="field2" mask="999"
requiredMessage="#{label.msg_requiredFields}"
required="true" styleClass="input smallest"
value="#{cc.attrs.cena.field.cp3Offline}"/>
<p:commandButton id="pesquisarId" styleClass="marginLeft" icon="ui-icon-search"
actionListener="#{pesquisarMorada.pesquisar(cc.attrs.cena)}"
update="resultPesquisaPanelId" process="@this field1 field2" immediate="true"/>
我发布你的问题的标题在谷歌和发现http://stackoverflow.com/questions/6062923/how-to-skip-validation-when-a-specific-button-is-clicked。所以区别在于你只需要两个字段? – Kukeltje
我在我看来有更多的字段是必需的。在这种情况下,按钮的动作不会被执行。解决方案? – Jorge
的可能的复制[如何让验证取决于按下的按钮?](http://stackoverflow.com/questions/8370675/how-to-let-validation-depend-on-the-pressed-button) – Kukeltje