Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8809629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:55:26+00:00 2026-06-14T02:55:26+00:00

Is there a way to display a specific JSF page based on the request

  • 0

Is there a way to display a specific JSF page based on the request URL?

Let’s say I have a JSF page “details.xhtml“. The managed bean “detailsBean” has a list of objects where each object has its own ID. Now if a user requests the page “../details.xhtml?id=1“, the list should be queried for an object with ID 1 and the resulting details page of this object should be displayed.

I already wrote a converter implementation class which can convert from object to ID and vice versa, but I don’t know how to use it properly. Do I have to work through the JAX-RS specification for this to work or is there a more simple solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:55:28+00:00Added an answer on June 14, 2026 at 2:55 am

    You can achieve this with plain JSF with the following steps

    1. Capture the ID in the request to determine what object is being queried for in your DetailsBean from the request parameter. There are many ways to achieve this, one of which is adding the following annotation to your managed bean (this is currently only permitted for a @RequestScoped bean, see why here).

         @ManagedProperty(value="#{param.id}")
         int requiredObjectId;
      

      The annotation above will capture the id parameter from the request and assign it to the requiredObjectId variable.

    2. Using the captured Id, setup your object in your bean in a @PostConstruct method

         @PostConstruct
         public void queryForObject(){
      
         //use the requiredObjectId variable to query and setup the object in the backing bean
      
         }
      

      The object retrieved should be assigned as an instance variable of your managed bean

    3. In your view, you could then reference the queried object that has been setup in the backing bean

        <h:panelGrid columns="2">
           <h:outputText value="Title"/>
           <h:outputText value="#{detailsBean.selectedObject.title}"/>
        </h:panelGrid>
      

    If your bean is in a scope broader than the request scope, you’ll need a combination of constructs to cleanly pull that request parameter before view rendering.

    1. Capture the request parameter within the JSF view itself using

      <f:metadata>
       <f:viewParam name="id" value="#{detailsBean.requiredObjectId}" required="true" requiredMessage="You must provide an Object Id"/>         
      </f:metadata>
      
          **OR**
      
    2. Due to the nature of JSF Lifecycle processing, doing the above alone may not make the value available for your use in time for object setup. You could use the following instead.

       <f:metadata>
          <f:event type="preRenderView" listener="#{detailsBean.setObjectId}" />         
      </f:metadata>
      

      What we’ve done here is specify a method (that captures the id) in the backing bean that must be executed before the view is rendered, ensuring that the id parameter is available as at the time you need it. Proceed with step 3, only if you’re using <f:event/> above.

    3. In the backing bean, you now define the setObjectId method

        public void setObjectId(){
      
        Map<String,String> requestParams =      FacesContext.getExternalContext().getRequestParameterMap();
        requiredObjectId =  Integer.parseInt(requestParams.get("id"));
      
        }
      

    Note that the above option is generally a work around/hack and not a clean solution as such

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to display an action-specific authorisation message for when an [Authorize]
Is there a way to display an image in the reminder notification page for
Is there a way to display a node label centered inside the node such
Is there a way to display flash applications using Gnash renderer (I'm not averse
is there a way to display the animated spinning wheel while the main thread
Is there a way to display and edit values in the PropertyGrid (and his
Is there a way to display the dropdown menu shown on sitepoint by mouse
I just wonder there a way to display the files in document directory with
When viewing submitted changelists in p4v, is there a way to display a particular
Is there any way to output/display information from a MATLAB program without an ending

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.