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 1107783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:59:08+00:00 2026-05-17T01:59:08+00:00

I have a JSP page (page1.jsp) showing a data table. There are also buttons

  • 0

I have a JSP page (page1.jsp) showing a data table. There are also buttons in the table like this:

<h:column>
    <f:facet name="header" >
        <h:outputText value=""/>
    </f:facet>
    <h:commandButton value="Show items" action="#{firstBean.displayItems}" immediate="true" />
</h:column>

The bean:

public void displayItems() throws IOException {
    MyClass theClass = (MyClass) dataTable.getRowData();
    String theId = theClass.getIdentityNumber();
    // ...
}

When we click on the button I want to move to another JSP page (page2.jsp). On page 2, there is also a data table. This table is created via a call to a bean called “facade” and a parameter (String – id). I.e when the button is pressed, I want to be moved to JSP page 2, and this page will display a datatable based on a call like this:

myList = facade.getDeliveriesById(theId);

So page 2 is dependent on stuff from page 1, either a string id, or if one can somehow set a list?

I guess the question is:

  • Should I in “firstBean.displayItems” make a redirect to jsp page 2 with a “get” paramater, after extracting this id (see above) ?
  • Is there a way of setting the list to be used on page 2 there in “firstBean.displayItems”?

What’s the normal way of going from one page to another in JSF (with data)?

  • 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-05-17T01:59:09+00:00Added an answer on May 17, 2026 at 1:59 am

    In JSF 1.x, the normal way is to return a String as navigation case outcome.

    public String displayItems() throws IOException {
        MyClass theClass = (MyClass) dataTable.getRowData();
        String theId = theClass.getIdentityNumber();
        return "page2";
    }
    

    in combination with the following entry in faces-config.xml:

    <navigation-rule>
        <navigation-case>
            <from-outcome>page2</from-outcome>
            <to-view-id>/page2.jsf</to-view-id>
        </navigation-case>
    </navigation-rule>
    

    It will then go to page2.jsf.

    On JSF 2.x, you don’t need the faces-config.xml. Just return the exact filename without extension, e.g. "page2" and JSF will then automatically locate the right view. This is called implicit navigation.


    Update: you seem to have a single “controller” bean per page and you’d like to share the data between those beans without referencing the other bean in the page. Very reasonable. This is doable by splitting the data out into another managed bean which is to be injected as managed property in the both “controller” beans.

    E.g.

    public class ControllerBean1 {
        private DataBean dataBean;
    
        public String submit() {
            MyClass theClass = (MyClass) dataTable.getRowData();
            String theId = theClass.getIdentityNumber();
            dataBean.setTheId(theId);
            return "page2";
        }
    
        // ...
    }
    

    And

    public class ControllerBean2 {
        private DataBean dataBean;
    
        // ...
    }
    

    You can access it in page2 like follows:

    <h:outputText value="#{controllerBean2.dataBean.theId}" />
    

    In JSF 1.x you need to inject it by <managed-property> in faces-config. You can find an example in this article. In JSF 2.x you can just annotate the managed property using @ManagedProperty. In future questions, please mention the JSF version you’re using. This way we can give more detailed suited answers without noise. JSF 2.x has namely pretty a lot of differences (improvements) in how things needs to be approached.

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

Sidebar

Related Questions

I have this simple Jsp page: <%@ page language=java import=java.awt.Color%> <% Color background =
I have a jsp page with two radio tags. The page contains a struts2
Right now I have a JSP page that allows to sort some items, when
On a JSTL/JSP page, I have a java.util.Date object from my application. I need
I have a list of bean objects passed into my JSP page, and one
I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I have a .jsp that contains an IFrame with a page that has some
I have a tree generated with JSTree in my JSP page (part of a
I have a JSP page that has 2 forms running on Tomcat 6. One
I have a JSP page that handles file downloads. I set the response header

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.