Pretty:link current page mappingId

Splash Forums PrettyFaces Users Pretty:link current page mappingId

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18434

    LaChamelle
    Participant

    Hi,

    I’m doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate Provider. The application run on Tomcat 7.27.

    I use PrettyFaces 3.3.3 for url management.

    Here my problem:

    I have a template that contains pretty:link(s) that allow to the users to change the lang of the current page. For the moment I change the lang and redirect to home.

    <ui:repeat ....>

    <pretty:link mappingId="home" styleClass="langue">

    <f:param value="#{acceptedLanguage}" />

    <f:param value="#{siteManager.visualId}" />#{acceptedLanguage}

    </pretty:link>

    </ui:repeat>

    I have different pages that implement the template. I would like to stay on the same page and only change the lang. The problem is that pretty:link required a mappingId.

    My url look like this:

    <url-mapping id="themes">

    <pattern value="/themes/#{lang : prettyUrlManager.urlLangId}/#{siteId : prettyUrlManager.urlSiteId}" />

    <view-id value="/theme/themes.jsf" />

    <action>#{prettyUrlManager.process}</action>

    </url-mapping>

    <url-mapping id="siteSettings">

    <pattern value="/siteSettings/#{lang : prettyUrlManager.urlLangId}/#{siteId : prettyUrlManager.urlSiteId}" />

    <view-id value="/admin/siteSettings.jsf" />

    <action onPostback="false">#{prettyUrlManager.processSiteSettings}</action>

    </url-mapping>

    For sure I can implement this ui:repeat in my template and use the specific view-id, but is it possible to said stay on the same view id, just change param ?

    Something like this :

    <ui:repeat ....>

    <pretty:link mappingId="wildCardCurrentView" styleClass="langue">

    <f:param value="#{acceptedLanguage}" />

    <f:param value="#{siteManager.site.visualId}" />#{acceptedLanguage}

    </pretty:link>

    </ui:repeat>

    Thanks.

    #22606

    You can get the ID of the current mapping with this code:

    PrettyContext.getCurrentInstance().getCurrentMapping().getId()

    So you could do something like this:

    public class MappingBean {
    public String getCurrentMappingId() {
    return PrettyContext.getCurrentInstance().getCurrentMapping().getId();
    }
    }

    And then use the value like this:

    <pretty:link mappingId="#{mappingBean.currentMappingId}">
    ...
    </pretty:link>

    I hope this helps! :)

    #22607

    LaChamelle
    Participant

    Great it’s exactly what I was looking for!

    I really like this project, it’s stable and maintain, easy to use, well documented.

    Moreover the team is available and always friendly to answer user request. Your technology should be integrated in JSF 3!

    Thanks you PrettyFaces team!

    #22608

    Thanks! :)

    I’m glad you like it. :)

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

You must be logged in to reply to this topic.

Comments are closed.