Pretty navigation with JSF action methods not working

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


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

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


    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" />

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


    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.



    There is no javascript. Source code of generated page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns=""><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" />


    <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?




    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.


    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.



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


    Awesome :) Glad you got it figured out.

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

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.