【发布时间】:2013-12-21 05:45:03
【问题描述】:
我正在使用 JSF 2,以及 Richfaces 4.x。我创建了一个在弹出窗口中的登录表单。弹出窗口没有正确提交和返回错误,也不允许我登录。
这是我的登录弹出窗口:
<rich:popupPanel id="loginPopup">
<h:form id="login" class="compact-form clearfix">
<h1>Access your Account</h1>
<fieldset id="inputs">
<h:outputLabel value="Username:" for="username"/><br/>
<h:inputText id="username" value="#{viewLogin.loginName}" required="true" requiredMessage="Please enter your username">
<f:validateLength maximum="20" minimum="3" />
</h:inputText>
<a4j:outputPanel ajaxRendered="true">
<h:message for="username" />
</a4j:outputPanel>
<h:outputLabel value="Password:" for="password"/><br/>
<h:inputSecret id="password" value="#{viewLogin.password}" required="true" requiredMessage="Enter your password">
<f:validator validatorId="LoginValidator" />
<f:validateLength maximum="20" minimum="5" />
</h:inputSecret>
<a4j:outputPanel ajaxRendered="true">
<h:message for="password" />
</a4j:outputPanel>
</fieldset>
<fieldset id="actions">
<a4j:commandButton value="Submit" id="submit" action="#{viewLogin.login()}" immediate="false"
execute="username password @this"
render="username password" oncomplete="if (#{facesContext.maximumSeverity == null}) {#{rich:component('loginPopup')}.hide();}"/>
<h:commandButton value="Cancel">
<rich:componentControl operation="hide" target="loginPopup"/>
</h:commandButton>
<h:link value="Forgot password?" outcome="forgotpassword"/>
<h:link value="Forgot username?" outcome="forgotusername"/>
<h:link value="Create account" outcome="createuser"/>
</fieldset>
</h:form>
</rich:popupPanel>
现在,当我按下提交按钮时,h:inputSecret 样式会发生变化,并且该字段没有登录输入类型密码并将显示我的密码。
为什么我的登录没有提交验证/呈现错误?
注意:该表单无需 popup 和 a4j 标签即可工作。
【问题讨论】:
-
另外,为了测试目的,添加一个通用的 rich:messages/h:messages 来检查它是否有其他抱怨 - 不要忘记让它重新渲染..