这是我在向导中按下“下一步”按钮后检查我的验证是否失败的尝试。这是在oncomplete中完成的 - 目前我只是显示一条显示未定义值的JS警报消息。我不认为后端bean在这里是相关的,因为验证是通过required = true触发的 - 没有进一步检查bean。
当前行为:警告框显示“未定义,然后显示验证错误消息”密码不能为空“
预期行为:警告框显示“true”,然后显示验证错误消息“密码不能为空”
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form prependId="false">
<p:dialog id="modalDialog" header="add user" widgetVar="userDialog" modal="true" width="640"
height="400" closable="true" appendToBody="true" visible="true">
<p:growl id="growl" sticky="true" showDetail="true"/>
<p:wizard widgetVar="wiz" effect="fade"
flowListener="#{userWizard.onFlowProcess}" showStepStatus="true" showNavBar="false" onback="progressBack();" >
<p:tab id="personal" title="Personal" >
<p:messages severity="warn" showDetail="true" autoUpdate="true" redisplay="true" />
<p:messages id="dialog_msgs" showDetail="false" autoUpdate="true" redisplay="true"/>
<p:panel style="height:150px;" >
<h:panelGrid columnClasses="label" columns="6" cellpadding="5">
<p:column>
<h:outputText value="Password: " styleClass="label" />
</p:column>
<p:column>
<p:password value="${userWizard.user.password}" styleClass="content" required="true"
requiredMessage="Password cannot be blank"/>
</p:column>
<p:column style="width: 50;">
<h:outputText value=" "/>
</p:column>
</h:panelGrid>
<h:panelGroup>
</h:panelGroup>
</p:panel>
<p:commandButton value="Previous" disabled="true" readonly="true" />
<p:commandButton value="Next" oncomplete="alert(args.validationFailed); wiz.next();" update="dialog_msgs" ajax="true" process="@this" />
</p:tab>
<p:tab id="personal2" title="Personal">
Not relevant
<p:commandButton value="Submit" update="growl messages @form"
actionListener="#{userWizard.save}"/>
</p:tab>
</p:wizard>
</p:dialog>
</h:form>
</h:body>
</html>