pretty:link and query parameter

Splash Forums PrettyFaces Users pretty:link and query parameter

This topic contains 9 replies, has 4 voices, and was last updated by  Sebastian Sachtleben 6 years, 4 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #17857

    timotius_pamungkas
    Participant

    How can I render a link like this using pretty:link

    e.g.: /pages/personal/po_payment_confirmation.jsf?po_header_id=#{personalPoBean.po_header_id}&payment_method=#{personalPoBean.payment_method}

    My PersonalPoBean class is @ViewScoped bean, and I already have following configuration on pretty-config:

    <url-mapping id=”po_payment_confirmation”>

    <pattern value=”/payment_confirmation” />

    <view-id>/pages/personal/po_payment_confirmation.jsf</view-id>

    </url-mapping>

    This pretty:link will work on primefaces datatable too, right? I’m trying to integrate prettyfaces to primefaces based on catagay’s suggestion, and it works well so far.

    Thanks

    #20641

    This is described (probably a bit too briefly) in the docs:

    http://ocpsoft.com/docs/prettyfaces/snapshot/en-US/html/components.html#components.prettylink

    The following should do what you want.

    <p:link mappingId="po_payment_confirmation">
    <f:param name="po_header_id" value="#{personalPoBean.po_header_id}" />
    <f:param name="payment_method" value="#{personalPoBean.payment_method}" />
    </p:link>

    Hope this helps! PS. Tell Catagay thanks ;) Let us know if you have any more issues!

    ~Lincoln

    #20642

    Yes, PrettyFaces links work from inside a datatable without problems. Just add the query parameters to your mapping like this:

    <url-mapping id="po_payment_confirmation">
    <pattern value="/payment_confirmation" />
    <query-param name="po_header_id">#{personalPoBean.po_header_id}</query-param>
    <query-param name="payment_method">#{personalPoBean.payment_method}</query-param>
    <view-id>/pages/personal/po_payment_confirmation.jsf</view-id>
    </url-mapping>

    See this chapter of the PrettyFaces documentation.

    Then you can create links for this mapping like this:

    <pretty:link mappingId="po_payment_confirmation">
    <f:param name="po_header_id" value="#{currentItem.id}" />
    <f:param name="payment_method" value="somePaymentMethod" />
    Click here
    </pretty:link>

    See the chapter on pretty:link for details.

    #20643

    Ups, concurrent posts! :-)

    #20644

    Muahahaaaaa :)

    #20645

    Hello,

    whats about string as Method return and parameters? For example I’m currently writing a forum in Seam 3 and use only Pretty Faces annotations for the views. So if a user creates a new topic I want to redirect to the new topic page but I have to pass the topic parameter somehow in return “pretty:board_topic”. Any ideas? I prefer to keep everything annotation based!

    Thanks,

    Sebastian

    #20646

    In this case you will simply have to write the desired value to the corresponding bean property before returning from your action method. When PrettyFaces builds the URL (for example board_topic) all parameter values for the mapping are extracted from the referenced bean properties.

    See this part of the documentation for details:

    http://ocpsoft.com/docs/prettyfaces/3.2.1/en-US/html/navigation.html#navigation.actions

    #20647

    Didnt get it to work. Please let clear that out. If I use this in my case:

    this.setForumPattern(forum.getPattern());

    this.setTopicId(Long.toString(topic.getId()));

    return “pretty:board_topic”;

    I set the value for boardNewTopicAction.forumPattern!

    But for board_topic the mapping requires the value for boardTopicAction.forumPattern. So finally I get the error:

    PrettyFaces: Exception occurred while building URL for MappingId < board_topic >, Required value < #{boardTopicAction.forumPattern} > was null

    #20648

    If you return pretty:board_topic from your action method, you will have to populate the value of #{boardTopicAction.forumPattern}. Something like this:

    @Named
    @RequestScoped
    public class SomeBeanWithActionMethod {

    @Inject
    private BoardTopicAction boardTopicAction;

    public void myActionMethod() {

    // do some more stuff
    ...

    // navigation
    boardTopicAction.setForumPattern("some-pattern");
    return "pretty:board_topic";

    }

    }

    Please post some more of you code if this still doesn’t work.

    #20649

    Works fine.

    Thanks for the quick help :)

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

You must be logged in to reply to this topic.

Comments are closed.