JSF - Loading bar while executing a Java method

1

Good morning, I have a login screen, and when the user clicks the Enter button, I want to be an incone showing "loading" while the java method is executed.

Follow my xhtml code:

<?xml version="1.0" encoding="UTF-8"?>

<title >Awake - Login Administrador</title>

                                           

            <h:panelGrid columns="2"  >
                <h:outputText value="Login: "  />
                <h:inputText value="#{loginAdmController.usuarioAdm.login}"></h:inputText>
                <h:outputText value="Senha: " />
                <h:inputSecret value="#{loginAdmController.usuarioAdm.senha}" />
            </h:panelGrid>

            <center>
                <p:commandButton action="#{loginAdmController.login}" update="pagLogin"   oncomplete="excluirManualDialog.hide()"   
                    value="Entrar" style=" margin-top: 10px;" />
            </center>

        </p:panel>
    </div>
</h:form>    

Can anyone help me?

    
asked by anonymous 27.05.2016 / 14:26

2 answers

3

Add this here on your page is a component of primefaces.

<p:ajaxStatus onstart="PF('statusDialog').show()" onsuccess="PF('statusDialog').hide()" />

<p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false">
            <h2>Aguarde...</h2>
            <img src="/img/ajaxloadingbar.gif" alt=""/>
</p:dialog>

you can purchase gif images here link

Do not forget to change the src of the image here

  <img src="/img/ajaxloadingbar.gif" alt=""/>

When you click on the button it will open a dialog, please wait ... and an image of a loading bar, circle etc ...

    
27.05.2016 / 16:24
3

In addition to what Washington has commented, you can also opt for the "p: blockUI" component. It will lock your screen and display something of your preference as a loading gif for example.

See an example of its usage below:

<p:blockUI block="form" trigger="btnSendData form:btnChanges formTable:dTable" >
    <p:graphicImage value="images/loading.gif"/> 
</p:blockUI>

If I repair, I pass in the block attribute the id of my form, which is what I want to block during my event. In the trigger I am passing the components that it will have to monitor to perform this action, for example my button to send my form "btnSendData" or some event in my table that is in another form (formTable: dTable), as load to change page for example.

For a closer look at the component documentation link

    
07.06.2016 / 19:29