WuR*_*WuR 2 validation dialog input jsf-2
我有两个p:对话框.每个包含一些标记为必需的输入字段.一次只显示一个对话框,但是当我在任何对话框上提交时,JSF也会验证未显示的对话框的输入字段.对于未显示的对话框,跳过JSF 2中的验证的最佳方法是什么.一种方法是我设置required ="condation".但是不知道那种情况会是什么,是不是会起作用.
最初隐藏每个对话框.每个人都有自己的按钮来显示.当一个处于活动状态并单击保存按钮时,即使必填字段具有值,也会出现验证错误.验证错误来自非活动对话框面板.可能会让我知道我想做什么.
UPDATE
<p:dialog header="Edit Group" widgetVar="dialog_groupEdit" resizable="false"
width="300" showEffect="bounce" hideEffect="explode" modal="true" position="center">
<h:panelGrid id="panel_groupEdit" columns="2">
<h:outputText value="Group Name: "/>
<h:inputText id="input_gnameEdit" size="26" value="#{groupBean.selectionGroup.gname}" required="true" requiredMessage="Edit Group: Name is required."/>
<h:outputText value="Description:"/>
<h:inputTextarea rows="6" cols="23" value="#{groupBean.selectionGroup.description}"/>
<div></div>
<p:commandButton value="Save" action="#{groupBean.saveGroupChanges}" oncomplete="#{args.validationFailed ? '':'dialog_groupEdit.hide()'}"
update="panel_groups panel_groupEdit" style="float:right;"/>
<div></div>
<p:message for="input_gnameEdit"/>
</h:panelGrid>
</p:dialog>
<p:dialog header="New Group" widgetVar="dialog_groupCreate" resizable="false"
width="300" showEffect="bounce" hideEffect="explode" modal="true" position="center">
<h:panelGrid id="panel_groupCreate" columns="2">
<h:outputText value="Group Name: "/>
<h:inputText id="input_gnameCreate" size="26" value="#{groupBean.createGroup.gname}" required="true" requiredMessage="New Group: Name is reqired."/>
<h:outputText value="Description:"/>
<h:inputTextarea rows="6" cols="23" value="#{groupBean.createGroup.description}"/>
<div></div>
<p:commandButton value="Save" actionListener="#{groupBean.saveGroupCreate}" oncomplete="#{empty groupBean.createGroup.gname ? ' ':'dialog_groupCreate.hide()'}"
update="panel_groupCreate panel_groups" style="float:right;"/>
<div></div>
<p:message for="input_gnameCreate"/>
</h:panelGrid>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
一种方法是我设置required ="condation".
这将是笨拙的.只需将每个单独的表单放在其自己的单独<h:form>
组件中,或使用该process
属性<p:commandButton>
来标识您要处理的区域.
<p:commandButton process="panel_groupEdit" ... />
...
<p:commandButton process="panel_groupCreate" ... />
Run Code Online (Sandbox Code Playgroud)
拥有"上帝"形式绝不是一种糟糕的做法.
归档时间: |
|
查看次数: |
3038 次 |
最近记录: |