Passing a query-param by annotation

Splash Forums PrettyFaces Users Passing a query-param by annotation

This topic contains 7 replies, has 3 voices, and was last updated by  Lincoln Baxter III 5 years, 6 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18258

    Tony Herstell
    Participant

    I am adding this to a controller (to reduce the amount of stuff in pretty-config.xml)

    @URLMapping(id = "error", pattern = "/error", viewId ="/pages/error/generalError.xhtml")

    and came unstuck as the “rule” was:

    <url-mapping id="error">
    <pattern value="/error"></pattern>
    <query-param name="exception">#{exception}</query-param>
    <view-id value="/pages/error/generalError.xhtml"/>
    </url-mapping>

    How do I pass the query-param?

    I tired

    pattern = "/error?#{exception}",

    and other combinations…

    #22338

    If you are using annotations to configure PrettyFaces you can annotate a field with @URLQueryParameter. In this case the value of the query parameter will be automatically injected into the corresponding bean property.

    See:

    http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.annotations.queryparams

    #22339

    Tony Herstell
    Participant

    Hi Christian,

    The message is being stuffed, by the JSF Exception handler override class I had to provide, into the request map so the “error” page can access it through el…

    In Exception Override bean:

    Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
    requestMap.put("exception", messageToReturn);

    On error page:

    <div class="error">
    <h:outputText escape="false" value="#{exception}" />
    </div>

    I do pass “params” elsewhere

    @SuppressWarnings("unused")
    @URLQueryParameter("cid")
    private String cid;

    but this is an odd case…

    #22340

    Yeah, this is something that the annotation configuration is not really good for. My recommendation would be to bind that property to a bean, like a regular query parameter, then access that parameter from your page.

    #22341

    Sorry, access the value in the bean from your page.

    #22342

    Tony Herstell
    Participant
    #22343

    Tony Herstell
    Participant

    Sorry; removed post.

    I though I have solved it.. but alas no….

    #22344

    Not sure what the problem you are having is, actually.

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

You must be logged in to reply to this topic.

Comments are closed.