我有一个Primefaces对话框,我需要在提交之前和之后进行验证。但是我没有意识到为什么必需的属性在我的代码中不起作用。我在表单登录中具有相同的必需属性,并且工作正常。
<ui:composition>
<h:body>
<h:form styleClass="aui">
<p:messages />
<fieldset>
<!-- Start Username -->
<div class="field-group">
<label for="df-username">#{msg['message.user.username.label']}<span class="aui-icon icon-required"> required</span></label>
<h:inputText type="text" styleClass="text" name="username" id="df-username" value="#{userBean.username}" required="True">
<f:validateLength minimum="4" maximum="30" />
</h:inputText>
<div class="description">#{msg['message.user.username.desc']}</div>
<p:messages for="df-username"/>
</div>
<!-- End Username -->
<!-- Start Password -->
<div class="field-group">
<label for="df-password">#{msg['message.user.password.label']}<span class="aui-icon icon-required"> required</span></label>
<h:inputSecret styleClass="text" name="password" id="df-password" value="#{userBean.password}" required="True">
<f:validateLength minimum="4" maximum="25" />
</h:inputSecret>
<div class="description">#{msg['message.user.password.desc']}</div>
<p:messages for="df-password"/>
</div>
<!-- End Password -->
<!-- Start Enabled -->
<div class="field-group">
<label for="df-enabled">#{msg['message.user.enabled.label']}<span class="aui-icon icon-required"> required</span></label>
<p:selectBooleanCheckbox styleClass="checkbox bk-checkbox" id="df-enabled" value="#{userBean.enabled}" />
<div class="description">#{msg['message.user.enabled.desc']}</div>
<p:messages for="df-enabled"/>
</div>
<!-- End Enabled -->
</fieldset>
<div class="bk-dialog-footer">
<p:commandButton styleClass="aui-button aui-button-primary bk-aui-button-form" image="aui-icon aui-icon-small aui-iconfont-success" oncomplete="handleDialogClose(xhr, status, args)" value="#{msg['message.save']}" actionListener="#{userBean.save}" />
<h:commandLink type="button" class="aui-button" onclick="PF('dlg-add-user').hide();return false;"><span class="aui-icon aui-icon-small aui-iconfont-close-dialog"/> #{msg['message.cancel']}</h:commandLink>
</div>
</h:form>
</h:body>
</ui:composition>
有任何建议吗?
答案 0 :(得分:0)
它是一个p:commandButton,你需要定义像
这样的过程域<h:form id="foo">
<p:commandButton process=":foo" update=":foo">
</h:form>
或使用ajax = false
禁用ajax<p:commandButton ajax="false">