Pretty navigation with JSF action methods not working

Splash Forums PrettyFaces Users Pretty navigation with JSF action methods not working

Tagged: 

This topic contains 7 replies, has 3 voices, and was last updated by  Lincoln Baxter III 5 years, 10 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18107

    m1m
    Participant

    When I use pretty:test in <h:link> it works, but in <h:commandLink> it goes to top of current page. Here’s the code:

    <url-mapping id="test">
    <pattern value="/test/" />
    <view-id value="/test.html" />
    </url-mapping>

    <h:form>
    <h:link outcome="pretty:test">test 1</h:link>
    <h:commandLink action="pretty:test">test 2</h:commandLink>
    </h:form>

    #21756

    It sounds like there may be some broken JavaScript on your page that is causing this issue. CommandLink uses JavaScript to do its work (usually,) because it simply submits the current form.

    #21757

    m1m
    Participant

    There is no javascript. Source code of generated page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head><link type="text/css" rel="stylesheet" href="/javax.faces.resource/theme.css.html?ln=primefaces-aristo" /></head><body>
    <form id="j_idt5" name="j_idt5" method="post" action="/test1/" enctype="application/x-www-form-urlencoded">
    <input type="hidden" name="j_idt5" value="j_idt5" />
    <a href="/test/">test 1</a>
    <script type="text/javascript" src="/javax.faces.resource/jsf.js.html?ln=javax.faces"></script>
    <a href="#" onclick="mojarra.jsfcljs(document.getElementById('j_idt5'),{'j_idt5:j_idt8':'j_idt5:j_idt8'},'');return false">test 2</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-1541740442815650100:-126604687361482346" />
    </form></body>

    </html>

    #21758
    <script type="text/javascript" src="/javax.faces.resource/jsf.js.html?ln=javax.faces"></script>
    <a href="#" onclick="mojarra.jsfcljs(document.getElementById('j_idt5'),{'j_idt5:j_idt8':'j_idt5:j_idt8'},'');return false">

    Is javascript ;)

    It comes from JSF, yes, but it could still be having issues. The only reason the command link would send you to the top of the page (without a redirect) is if the javascript on the commandLink failed to submit the form.

    Are you sure the page is not refreshing, and is simply moving to the top of the screen?

    ~Lincoln

    #21760

    m1m
    Participant

    Page is refreshing. I also tested with <h:commandLink action=”/test”>test 3</h:commandLink> and it’s working fine! Source code is the same, so I think this could be bug in prettyfaces. I debugged with firebug, and only difference is ‘Location’ header in server response i.e. in test3 location is set with new view-id and in test 2 location header is absent.

    #21761

    Did you test with this minimal example you posted or is it more complex in your page and you just reduced it for your post? If so, are there inputs on the page? Perhaps there is a validation failure and therefore the current page is rendered again.

    #21762

    m1m
    Participant

    OK, problem solved. The bug was in my custom NavigationHandler. I just added exception for outcome starting with ‘pretty:’ and it’s working.

    #21763

    Awesome :) Glad you got it figured out.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Comments are closed.