Prime P Dialog Box:

My p: the dialog keeps loading and again, I need it to appear only once. Does anyone know how to do this?

    <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>
    ...

Button:

  <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>

Login () in LoginBean:

    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;
     }

I have one customAuthenticationProvider that returns "ATIVACAO" when the database is empty, so I need to open this dialog to insert data, but it continues to open (closes immediately).

+5
source share
1 answer
  • <h:body onload="dialogAtivacao.show();"/>converted when an <body>HTML tag is loaded , displays a popup. The tag <body>will reload when a full page reload occurs.

  • <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"/> will trigger a full page refresh every time a button is clicked.

, , ,

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"/>

, ajax, onload

+3

All Articles