Help regarding passing parameter

Splash Forums PrettyFaces Users Help regarding passing parameter

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24685

    neeraj
    Participant

    Hi All,

    As a newbie, I recently started using prettyfaces for url shortening, it seems be working fine on most of the cases except few. One of the major issue which I am not able to solve is,passing parameter.

    Actually in my application, when a page is accessed through menu first time, we pass a query param as a indicator and based on that we do certain clean activities. But in subsequent request for the same page we don’t pass the query param hence no cleanup activities are done.

    I am not sure how I can achieve same behavior while using pretty faces. I tried sending request param along with pattern ‘/pr/li’ ( e.g. http://myserver/pr/li?frommenu=true which maps to http://myserver/provision/list.xhtml?frommenu=true) but this doesn’t help, actually I noticed the request param becomes the part of form action URL and hence subsequent post still has the param eventually creating the issue.

    I am sure that there is a right way which I am not doing, help is appreciated.

    thanks.
    neeraj

    #24748

    Sorry for the delayed response. I think there is a simple way to do what you want. You should use an page action in your mapping. In this page action your can do the cleanup work if the query parameter is present. After cleaning up, you can set the query parameter field to null. This way PrettyFaces won’t add it to the postback URL any more.

    Pseudo code:

    
    <url-mapping id="somePage">
      <pattern value="/some-url/" />
      <view-id value="/faces/some-view.jsf" />
      <query-param name="frommenu">#{myBean.fromMenu}</query-param> 
      <action>#{myBean.pageAction}</action>
    </url-mapping>
    
    public class MyBean {
    
      private String fromMenu;
    
      public void pageAction() {
        if("true".equals(fromMenu)) {
          cleanup();
          fromMenu = null;
        }
      }
    
      /* getters + setters */
    
    }
    

    I hope this helps. 🙂

    #24784

    neeraj
    Participant

    Thanks, this change is working.

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

You must be logged in to reply to this topic.

Comments are closed.