• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF 1.3 Navigate web pages and pass parameters

 
Sally Forge
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using JSF 1.3 Unfortunately I will not be able to upgrade to JSF 2.0. I am looking for a solution to the following problem. I have researched this for a while and have not successfully figured out how to do it.

On my index.xhtml page I have a datatable. It is populated from a backing bean. The datatable has 1 column. The goal is for the user to be able to click on an entry in the datatable and upon clicking on the entry, the user should be brought to the web page detail.xhtml. The detail.xhtml page also has a datatable that should be populated based on the entry the user clicked on the index page. This means that somehow I have to navigate and pass a parameter or somehow get the data to the backing bean so it can be used to populate the table in detail.xhtml

I have tried commandButton and commandLink but perhaps I am using them incorrectly.

Your help is very much appreciated. Thanks.
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are lots of option for you to try. Please see this link
 
Sally Forge
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for responding. I have gone through all of the contents in the link that you provided and still cannot figure it out. The answer may be in the link but I just cannot see it for some reason. Can you point me to the location on the page? I have also tried to implement some of these solutions and did not have succes yet.

Thanks.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought that JSF went from 1.2 to 2.0 and there was no 1.3.

Regardless, the same technique is recommended for any JSF version, whether 1.x or 2.x. DON'T select table rows by passing parameters. Putting parameters on a JSF View definition essentially violates the Model/View/Controller contract, and specifically, MVC as implemented in JSF, where Views should contain only minimal logic, and that logic should be restricted to controlling View rendering, and Controllers (generally) are not user-written, but supplied as part of JSF itself.

If I hand you a piece of paper with a table on it, do you think of that paper as the embodiment of a loop, or as a 2-dimensional display of data? If you think of it as a loop, you've revealed yourself as a programmer for all the world to see, since normal people think first of the data, and not of how the data got there. JSF works that way as well. In theory, a datatable could have just as easily been rendered by splitting the model data rows into parallel streams for some ultra-evil graphics card to render as parallel operations. Thinking of 2-dimensional displays in 1-dimensional terms is self-limiting.

A dataTable is a 2-dimensional graphical construct on the view. It is rendered from a 2-dimensional DataModel object (and, as I said, HOW it gets rendered is beside the point).

When you click on a commandButton or commandLink in a row of that table, likewise, JSF doesn't think about looping, it thinks about what row in the model corresponds to that row of the table. The DataModel contains cursor information that allows the action method to determine which row that was selected without being fed an external parameter. Which is just as well, since action methods don't take parameters. This cursor information is why you cannot effectively reference a List or array as the value of a dataTable. There's no place to hold that context in a simple generic sequential set of records.

In other words, use the getRowData() method of the table's dataModel to gain access to the row that the user clicked on and leave parameters off the View definition. And, of course, remember that dataModels only work in session-scope beans. request-scope beans are destroyed and re-created every time, destroying the critical cursor information in the process.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!