Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unwanted bean instantiation when clicking a link

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ListBean is the backing bean (request scope) for a list of links to items. The constructor can take quite awhile to run (e.g. 30 seconds).

ItemBean is the backing bean for an individual item. The constructor runs quite quickly (e.g. 1 second).

A user goes to the List screen, and the ListBean constructor runs and generates a list of links to items. The links were created by t:commandLink tags.

The user clicks on an item in the list to view the item's details.

The ListBean constructor runs again, taking 30 seconds to do so, even though we don't actually want to do anything with the ListBean.

Finally, the ItemBean constructor quickly runs and the item details are displayed.

How can I avoid the unnecessary running of the ListBean constructor? I have "immediate='true'" on the t:commandLink tags, but of course that doesn't prevent the constructor from running.

I'm guessing my only real option is hutputLink, but so far as I know I can't specify a method to be run the way I can with t:commandLink, nor can I attach an actionListener to it.

I suppose another possibility is to change the ListBean to session scope, but then I need to modify my logic to ensure that the bean is refreshed when the list screen is displayed.

Any ideas?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic