How to config the pretty-config.xml for primeFaces showcase?

Splash Forums PrettyFaces Users How to config the pretty-config.xml for primeFaces showcase?

This topic contains 4 replies, has 2 voices, and was last updated by  xuzhike 11 years, 2 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17798

    xuzhike
    Participant

    Hello Lincoln,

    I am planning to use PrettyFaces for my project which will use PrimeFaces. and I am trying to test the rewriting in PrimeFaces showcase. but something make me confused.

    here is my testing step:

    1: before applying PrettyFaces,the showcase is as following:

    1) when first acccess pagg, input:

    http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT

    it will change to: http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT/ui/home.jsf

    2) click any link, for example, “slider”, the URL changes to:

    http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT/ui/slider.jsf

    All xhtml pages are in the same folder : prime-showcase-1.0.0-SNAPSHOTui

    no sub-folders.

    2: I add PrettyFaces into the showcase and add the following pretty-config(basing on the sample in prettyFaces doc):


    <url-mapping id=”home”>

    <pattern value=”/” />

    <view-id>/ui/home.jsf</view-id>

    </url-mapping>


    1) so if I access: http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT

    it works and change to: http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT/

    it is correct, right?

    2) but I hope if I click the link “slider”, the URL should show:

    http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT/ui/slider

    (or http://localhost:8080/prime-showcase-1.0.0-SNAPSHOT/slider)

    what should I config?

    I have no idea for this setting. because from the doc, I found all files in <view-id> are located in different sub-folder, NOT in same folder.

    Please help to provide idea/solution.

    Thx a lot.

    #20290

    xuzhike
    Participant

    BTW, all links use the tag <li contains <a,

    href=”#{request.contextPath}/ui/slider.jsf”

    href=”#{request.contextPath}/ui/ajax/ajaxHome.jsf”

    #20291

    You need a mapping for each view file. PrettyFaces will not “clean up” URLs for resources unless you tell it to:

    <url-mapping id="slider">
    <pattern value="/slider" />
    <view-id>/ui/slider.jsf</view-id>
    </url-mapping>

    <url-mapping id="ajax">
    <pattern value="/ajax" />
    <view-id>/ui/ajax/ajaxHome.jsf</view-id>
    </url-mapping>

    Also, if the links are hard-coded with HTML, not using JSF components, I highly doubt that PrettyFaces will alter the HREF attribute. You’ll need to change these over to use <h:link> instead. Then PrettyFaces will correctly be able to modify the URLs.

    <h:link target="/ui/slider.jsf"/>
    <h:link target="/ui/ajax/ajaxHome.jsf"/>

    #20292

    xuzhike
    Participant

    Hi, Lincoln,

    thx for your reply. per testing the two setting, found the first one which just setting a mapping for each view file, for example:

    <url-mapping id=”slider”>

    <pattern value=”/slider” />

    <view-id>/ui/slider.jsf</view-id>

    </url-mapping>

    the result is not expected. still show /ui/slider.jsf

    for the second config, <h:link target=”/ui/slider.jsf”>slider</h:link>

    it always links to the previous link, it is too strange.

    but if I change the tag to <h:outputlink>, it works as expected.

    #20293

    xuzhike
    Participant

    Hi, Lincoln,

    per testing again, found the following two setting works as expected:

    <url-mapping id=”calendar”>

    <pattern value=”/calendar” />

    <view-id>/ui/calendarHome.jsf</view-id>

    </url-mapping>

    1) <h:link outcome=”/ui/calendarHome.jsf”>calendarHome Test</h:link>

    2) <h:outputLink value=”#{request.contextPath}/ui/calendarHome.jsf”>TEST</h:outputLink>

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

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

Comments are closed.