Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

click to view details in h:dataTable  RSS feed

 
Vimal Kumar Venugopal
Ranch Hand
Posts: 43
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Rangers,

I am in running into troubled waters due to a functionality. Issue tickets are shown to user through a h:datatable tag. The user should be able to view details of the ticket when he clicks on any of the entry in the issue ID column of the datatable.

To implement my functionality, I split it up into three tasks.
FIRST, get the value of the issue ID the user clicked on.
SECOND, run a method to collect the details of the issue id from the service method.
THIRD, goto a page where issue details are displayed through a transfer object.

Now, I am failing to get the first one itself. Even though I was able to get a hint to keep the managed bean in session scope, I do not want to use this as this will stale the user's screen. I tried moving the list alone which populates datatable to a session scope, but I could not do the talking between to and froth with the managed bean for query string and list.

And am insanely confused on how to do step II and step III in one go..!!

By the way, Am using data transfer object as my design pattern.

Truly appreciate your concern.
Ron
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DTOs are obsolete. They were needed when EJBs carried persistency freight, but in JPA/EJB3, you can simply detach the model object and use it as its own DTO.

Don't try to force some other paradigm on JSF. It will cost you more than it will gain you. JSF isn't as capable as most J2EE frameworks of using request-scope objects thanks to its postback mechanisms, and in particular, you can't do a viable tableModel object at Request scope. If you don't like session scope and you're using JSF2, use View scope. View scope is a session scope that deletes itself automatically when you leave the current page to avoid cluttering up the session with objects no longer of interest.

The easy way to do what you're describing is to use a dataTable on a View of View or Session scope. You CANNOT use Request scope, because the cursor information is saved in the DataModel, and the request-scope DataModel is destroyed at the end of each Request, just like every other Request-scope object.

If you use a commandLink or commandButton on each table row to trigger item editing and/or display, the action method can use the dataTable's DataModel to determine which item (row) was selected via the getRowData() or getRowIndex() methods. You can then use that to retrieve the item of interest and work with its details. The action method would then navigate to the detail view/edit page.
 
Vimal Kumar Venugopal
Ranch Hand
Posts: 43
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:You CANNOT use Request scope, because the cursor information is saved in the DataModel, and the request-scope DataModel is destroyed at the end of each Request, .....


Thanks a lot Tim for the very much detailed explanation. I do understand now why the task seemed to be daunting..
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron Fields wrote:
Tim Holloway wrote:You CANNOT use Request scope, because the cursor information is saved in the DataModel, and the request-scope DataModel is destroyed at the end of each Request, .....


Thanks a lot Tim for the very much detailed explanation. I do understand now why the task seemed to be daunting..


As long as you follow recommended practices for JSF, this common operation isn't that hard. The problem arises when people try and force their old ways of doing things, passing parameters, coding listeners, binding controls and so forth, hammering a round peg in a square hole.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!