pretty: And Path Params

Splash Forums PrettyFaces Users pretty: And Path Params

This topic contains 5 replies, has 3 voices, and was last updated by  Christian Kaltepoth 9 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #18675


    i’m using a set of nested url-mappings where the top-most one is the “language” mapping:

    <url-mapping id="language">
    <query-param name="language">#{currentUser.language}</query-param>

    <url-mapping id="dashboard" parentId="language">
    <pattern value="/dashboard/" />
    <view-id value="/faces/index.xhtml" />

    <url-mapping id="processManagement" parentId="language">
    <pattern value="/processManagment/" />
    <view-id value="/faces/processManagment.xhtml" />

    <url-mapping id="processInstanceDynamic" parentId="processManagement">
    <pattern value="#{ /start/ taskViewController.action}/#{ taskViewController.processName}/" />
    <view-id value="/faces/taskview.xhtml" />

    Now i want the user to be able to switch the language without “falling back” on the index site or sth. so i used “pretty:”

    <h:link outcome="pretty:" title="Italiano">
    <f:param name="language" value="it" />

    This works well for the static cases, where NO Path Params are defined.

    If the user currently views a page like


    I expected the above link to generate /start/process1/?language=it

    instead pretty faces generates /faces/taskview.xhtml?language=it until i manually “add” the action and processName parameter via f:params, which i don’t want, because different sides will use different path-parameters…

    What am I doing wrong right here?


    If you want to use <pretty:link>, then unfortunately you must specify all necessary parameters or the link will not be generated in the rewritten form. You should be able to pull these parameters from your backing beans:

    <h:link outcome="pretty:" title="Italiano">
    <f:param name="language" value="it" />
    <f:param name="action" value="#{myBean.action}" />
    <f:param name="processName" value="#{myBean.processName}" />

    There is no avoiding this with <pretty:link> :) However, if you use a standard JSF2 <h:link includeViewParams="true">, then you may be able to do what you want to do via omitting the parameters, and PrettyFaces will figure out how to fix the URL for you automatically. No guarantees :) Try it out and let me know what you get working.


    Ah, I read your post a little too quickly, I think you are missing the flag includeViewParams="true" in your <h:link>



    I’ve added includeViewParams="true" but with no effect.The links are still pointing to the view-id instead of using and filling the pattern.

    But well… Going back to “old school” HTML fixed the problem:

    <a href="?language=de" title="German">German</a>

    does ofc. exactly what i want it to do: Take the current url and append (or overwrite) ?language=de


    But one question about the “value filling” still remains:

    Inside my main menu, i use the definied pretty ids, like so:

    <h:link outcome="pretty:dashboard" class="shortcut-dashboard" title="Dashboard">Dashboard</h:link>

    This results in the simple Page /dashboard/ to be shown (as expected). But when I return pretty:dashboard to a commandButton action, pretty faces automatically appends the language: /dashboard/?language=current

    Why does it append the language in one case, but not in the other?


    If you return pretty:something from an action method, PrettyFaces will extract the current value of #{currentUser.language} to build the URL. This way you will always be redirected to the URL with the current language.

    If you use <h:link> or <pretty:link> this is not the case because you typically do not want to link to a page using the “current” value of something. This makes sense because typically you have something like object IDs as path or query parameters. So you have to specify the path and query parameter values using <f:param> in this case.

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

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

Comments are closed.