RequestContext runs twice

0

I want to send a function of Js from a Jsf bean with RequestContext, but for some strange reason the function is executed twice.

This is the code of my xhtml:

<h:form >
    <p:commandButton class="btn" 
        value="Llamar js Function" 
        action="#{developerController.foo}"/>
</h:form>

This is my bean code:

@Named(value = "developerController")
@SessionScoped
public class DeveloperController implements Serializable {

@EJB
QuoteManager quoteManager;

public DeveloperController() {

}

public void foo() {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.execute("alert('Hola');");
}


}

What should I do to have the "alert ()" run one instead of twice?

I'm using primefaces 6.0 and Glassfish 4.1

    
asked by gibran alexis moreno zuñiga 23.01.2017 в 18:54
source

1 answer

0

Use actionListener instead of action , since the action method is used for redirection and should return a String that must match your navigation rules.

Probably being a method that does not return anything is giving you the problem when trying to redirect yourself.

Greetings.

    
answered by 27.01.2017 в 01:34