Cat*_*ish 5 java jsf dialog opacity primefaces
我有一个页面模式对话框,如果用户单击编辑按钮,则会呈现该对话框.该对话框要求输入用户名和密码,并有一个提交按钮.如果用户名和密码未验证,则会显示错误.
问题是,如果用户名和密码不进行身份验证,则每次身份验证失败时,模式背景会越来越暗.
会导致什么?
<p:dialog id="dialog" header="Login To Edit" widgetVar="dialog" visible="#{fundingBacker.loginVisible}" modal="true"
resizable="false" closable="false" draggable="true" rendered="#{!userBean.loggedIn}">
<h:form>
<p:ajaxStatus style="width:16px;height:16px;">
<f:facet name="start">
<p:graphicImage value="../images/loading4.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<p:messages autoUpdate="true" showDetail="true" />
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="lanId" value="LanID:" />
<p:inputText value="#{currentUser.lanID}" id="lanId" required="true" label="lanId" requiredMessage="Lan ID is required" />
<h:outputLabel for="password" value="Password:" />
<p:password value="#{currentUser.password}" id="password" required="true" label="password" feedback="false" requiredMessage="Password is required" />
<p:commandButton id="loginButton" value="Login" type="submit" styleClass="primaryButton" action="#{currentUser.performLogin}" update="dialog"/>
</h:panelGrid>
</h:form>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
您每次都会更新对话框,而无需先关闭它。我不确定这是一个错误还是一个功能,但由于该visible属性,覆盖层会在每次对话框更新时重新初始化。您可能想将其连同更紧凑的测试用例一起报告给 PrimeFaces 人员。
最简单的解决方案是关闭 ajax 成功的对话框。它重新显示的速度将比最终用户眨眼的速度快。
<p:commandButton ... onsuccess="dialog.hide()" update="dialog" />
Run Code Online (Sandbox Code Playgroud)
您可能只需要微调visible和rendered属性,以确保在验证失败时(例如,当用户仍未登录时)重新打开对话框。
另一种方法是更新对话框的表单而不是对话框本身。
<p:commandButton ... update="@form" />
Run Code Online (Sandbox Code Playgroud)
或者完全删除该属性。它默认为@form已经。
<p:commandButton ... />
Run Code Online (Sandbox Code Playgroud)
然后可以通过 完成登录成功后关闭对话框RequestContext#execute()。
RequestContext.getCurrentInstance().execute("dialog.hide()");
Run Code Online (Sandbox Code Playgroud)