Menu link to the currently viewed page

Splash Forums PrettyFaces Users Menu link to the currently viewed page

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

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • #18104

    Piotr Findeisen


    Using JBoss 4.2.3, Pretty Faces 3.3.0 or 3.3.2, JSF1.2 built.

    I’ve a pretty-config.xml with a mapping like this:

    <url-mapping id="listing" onPostback="false" outbound="false">
    <pattern value="/listing" />
    <!-- OR pattern value="/views/listing.xhtml" /-->
    <query-param name="type" onPostback="false">#{Bean.filteringType}</query-param>
    <view-id value="/views/listing.xhtml" />

    And have a page “/views/listing.xhtml” with jsfId “menuListing”.

    When i invoke navigation with navigation string of “menuListing” from any page of the application, everything works fine. However, when i invoke the navigation being actually on the page “views/listing.xhtml”, current URL is taken, even *regardless* of the actual value of #{Bean.filteringType}.

    What I actually would expect is that the Pretty Faces does not kick in at all (since outbound=”false” attribute is used).

    What do i do wrong?

    Thanks for help & best regards,



    How are you generating the link?


    Piotr Findeisen

    I tried two methods:

    1. using richfaces HtmlMenuItem with actionExpression: javax.el.ExpressionFactory.createMethodExpression(ctx, "menuListing", String.class, EMPTY)

    2. returning “menuListing” from an action method as a standard navigation string

    Both have same effect.


    This sounds like correct behavior. If you are using JSF navigation without doing a redirect, PrettyFaces is not getting involved. That is still the case here. Take a look at your Form URL. It should be the URL of the current Page.

    When you click the navigation link, you are actually submitting the form back to the URL of the current page, and then JSF simply renders the new content under that URL. That’s why you want to use a redirecting navigation instead.

    If you use jSF navigation for this, PrettyFaces will indeed not do anything for you. I’m guessing you need to do a redirect in order to see the updated URL, though I’m surprised you are not seeing this from your other pages as well.



    Piotr Findeisen

    I have built the application without pretty faces, and now the behavior is different.

    If I do any of those:

    1. click in the menu for “menuListing”

    2. invoke an action that returns nagivation string “menuListing”

    current GET parameters are cleared. This is the behavior I expect, by the way, also when Pretty Faces is included in the application.

    Best regards,



    Piotr Findeisen

    This is because in PrettyViewHandler.getActionURL there is a code like this:

    public String getActionURL(final FacesContext context, final String viewId)
    PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
    if (prettyContext.isPrettyRequest() && !prettyContext.isInNavigation() && (viewId != null)
    && viewId.equals(context.getViewRoot().getViewId()))
    URL url = prettyContext.getRequestURL();
    QueryString query = prettyContext.getRequestQueryString();
    String contextPath = prettyContext.getContextPath();

    String target = contextPath + url + query.toQueryString();
    return target;
    return parent.getActionURL(context, viewId);

    The if catches, because prettyContext.isInNavigation() returns false — my application provides its own navigation handler, which calls:

    acesContext.getApplication().getViewHandler().getActionURL(facesContext, viewId)


    Piotr Findeisen

    Hi Lincoln,

    As you see i found the root cause of my problem, so i was able to apply a workaround in my own navigation handler.

    Shall I consider this root cause a bug? If so, should I report it somewhere in more formal way?

    Or it’s just a matter of misconfiguration — and i didn’t need to change navigation handler’s code at all?




    Awesome! Yes, sorry. Been a bit busy here.

    I don’t think this is a bug. Do you? If so, why? (Seriously asking, I want to make sure I am seeing this the same way you are :)

    The problem here is that PrettyFaces really has no way to control the form URL in JSF other than this getActionURL() method, which is why this feature exists.



    This is the related JSF spec issue: (which would need to be fixed in order to make this easier for you to work with.)


    Piotr Findeisen

    Thanks for the explanation. So this is deficiency in the JSF API?

    I don’t say that the cited code is a bug — and know i understand what it does. However this has the other end, that is my use case:

    I’m on a page X, possibly with parameter a=Y, and want to navigate using site menu entry, a link on the page or JSF navigation/outcome string to the very same page X.

    This should clear parameters (a=Y) but with Pretty faces — it does not.

    I could work around this patching my navigation handler with some pretty-faces-related logic. If this is required step when using pretty faces, it should probably be mentioned in the docs.




    You shouldn’t need to change code if you use redirecting navigation from JSF. (Add the <redirect/> tag to your navigation case.

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

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

Comments are closed.