我的 p:dialog 不断加载,我只需要它出现一次。有人知道该怎么做吗?
<h:body style="background: url('img/background/teste/brushed_alu.png')!important" onload="dialogAtivacao.show();">
<script type="text/javascript">
$(document).ready(function() {
document.getElementById("j_username").focus();
});
</script>
<p:dialog id="dialogAtivar" header="Ativação de empresa" showEffect="drop" hideEffect="drop" resizable="false"
widgetVar="dialogAtivacao" modal="true" closable="true" rendered="#{sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message == 'ATIVACAO'}">
<ui:include src="pages/ativacao/AtivacaoEmpresa.xhtml"/>
</p:dialog>
...
按钮:
<p:panel styleClass="panelBotaoLogin" >
<h:commandButton id="saveButton" action="#{login.doLogin()}" value=" Entrar" styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only botaoEntrar"/>
</p:panel>
LoginBean 中的 login() :
public String doLogin() throws IOException, ServletException {
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
RequestDispatcher dispatcher = ((ServletRequest) context.getRequest()).getRequestDispatcher("/j_spring_security_check?j_username=" + username + "&j_password=" + password);
dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());
FacesContext.getCurrentInstance().responseComplete();
return null;
}
我有一个 customAuthenticationProvider 在数据库为空时返回“ATIVACAO”,因此我需要打开此对话框来插入数据,但它会不断重新打开(关闭并立即重新打开)。