Search code examples
jsfjsf-2richfaces

jsf richfaces a4j:jsFunction forward outcome


Is it possible to create a4j:jsFunction that will call a method inside my managed bean and from there to perform forward to another jsf page ?

Thank's In Advance.


Solution

  • No, it's not possible because the <a4j:jsFunction> will create a javascript method available in the HTML that communicates with the server via Ajax. Instead, you could do something ugly like this:

    <h:form id="myForm">
        <a4j:jsFunction name="myJSFunction" action="#{myBean.jsLogic}"
            oncomplete="document.getElementById('myForm:btnForward').click();" />
        <a4j:commandButton id="btnForward" style="display: none;"
            action="#{myBean.doForward}" />
    </h:form>
    

    In this case at the end of your js function, you will call the method of a <a4j:commandButton> (also <a4j:commandLink> or any other h component) that could do the navigation.