Asp*_*ect 6 jsf primefaces jsf-2
我的p:对话框继续加载,我需要它只出现一次.谁知道怎么做?
<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>
...
Run Code Online (Sandbox Code Playgroud)
按钮:
<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>
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)
我有一个customAuthenticationProvider在数据库为空时返回'ATIVACAO',所以我需要打开此对话框来插入数据,但它会一直重新打开(关闭立即重新打开).
<h:body onload="dialogAtivacao.show();"/>
翻译为当<body>
加载 HTML 的标签时,显示弹出窗口。<body>
当视图的整页重新加载发生时,该标签将被重新加载
<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"/>
每次单击按钮时都会触发整页刷新。
总之,每次我单击此按钮时,都会重新加载整个页面并显示对话框
使用 ajax 命令组件代替:
<p:commandButton id="saveButton" action="#{login.doLogin}" value=" Entrar" styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only botaoEntrar"/>
Run Code Online (Sandbox Code Playgroud)
这样就触发了ajax请求,并且onload
只触发一次
归档时间: |
|
查看次数: |
1394 次 |
最近记录: |