Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

newbe question on JSF  RSS feed

 
Gerald Pape
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting depressed now - I cant find any helpfull information - OK I dont get it,.....

What I have:
Customer[] customer
Order[] orders

What I want:
JSF Page 1 with a data table showing all possible customers (I succeeded with that part) and when a command Hyperlink is clicked show Page 2 only with orders from the Selected customer.

What do I have to do to get the selected Customer over to Page 2 - and how can I bind the Data Table to just the orders belonging to the customer.

Just to make sure - I know how to filter the orders and so on - the point I am missing is - how to get the selected customer from page 1 to page 2 - and how to bind the data table with the filter.

thanks for any help !
 
Rajesh K. Ilango
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had one such requirement. Following is what I did.

In the Customer class I added a new instance variable "boolean selected" with proper getter and setter methods. In the JSF page I added checkboxes for this boolean field. Now if you sumbit them then the value will get set in the valuesObjects in the array.

You can loop thru. and find the value in "selected" variable to find which all where selected by the user. In my case I am using a pagination component, so I loop thru. the rendered sub array only.
 
Henry Lowell
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how I do it:

Create a property in your page1 backing bean of type UIData. Create getters and setters for said property.

Using the binding attribute on your datatable, bind this UIData object to your data table. In the action method for you commandLink do the following:

SomeObject myObject = (SomeObject)uiData.getRowData();

Then there are a couple of ways that I know of to pass this object to the other page. You can place it requestScope like so:



Does this seem silly? Yes. Now, what I am thinking about trying is the following. I can get an instance of a managed bean in Java code. If I can get an instance of Page2 and just apply a setter property to set the object I am passing to page2 then when the request is forwarded after the action, I should have the object. Tapestry works this way, but they make it a bit easier to deal with. I'll have to do some testing and get back with you on that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!