Doubt Java Server Faces

Asked

Viewed 62 times

0

I’m doing a JSF application, I have a Bean class that has a method. In this method I have a variable of type String and as the method is running, the variable is updating values.

I wonder if it is possible at runtime to update a component textarea where this variable is being displayed?

<p:inputTextarea id="display" rows="15" cols="50" 
    value="#{fluxoPeriodo.displayMessage}"/>

Remembering that the update only occurs when the method finishes the execution

Dialog para descrição de processos

Every time you go through a method, I’d like him to fill in the information.

    int flag = 0;

    flag = isNum2();
    mess(flag);
    FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add("idformdialog:display");

    try{ Thread.sleep(8000); 
    } catch (InterruptedException ex) {} 

    flag = isNum3();
    mess(flag);
    FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add("idformdialog:display");

I have a flag variable of the whole type that takes the value of isNum(), when passing through this method receives an integer value, and then passes to the method mess(flag). Depending on the flag value, the method should return a message, but the problem is that it is only showing the messages when the method in which the methods are being executed ends its execution.

<p:commandButton value="Buscar" id="pesquisa"
        class="ui-button-custom ui-button-busca"
        action="#{fluxoPeriodo.teste}" process="@form"
        update="@form" 
        onclick="PF('statusDialog').show();">                               
</p:commandButton>

Above the button where I call the test method, which methods above are being processed.

Any suggestions?

  • You want to update the field during the execution of the method?

  • Exact, the inputTextArea should receive the information during the process, I want to create something like.

  • Has the field update by the bean Managed worked? I don’t understand exactly what the problem is now

  • I still can’t get it to work.

  • The problem is this, after going through the method should update a value in my paginá.xhtml, but it is only updating when the method by which I call by commandButton end execution. In this action method there are other methods being executed, after each of them would like you to update a message.

1 answer

1

With Primefaces 6.2 you can use the following command inside your Managed Bean:

PrimeFaces.current().ajax().update("form:id:meu:campo");

In the case of pure JSF, you should add your field id in the context of partial view rendering:

FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add("form:id:meu:campo");

Throughout your method you can update the field as the Steps of your process are completed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.