Register / Login
Win a copy of
The Way of the Web Tester: A Beginner's Guide to Automating Tests
this week in the
Unwanted bean instantiation when clicking a link
posted 7 years ago
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 h
utputLink, 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.
insert a new row in a datatable
Show modal from rich:picklist onlistchanged?
c:forEach is not working
Validation error while trying to change a value in a request scope bean
HashMap mapped property / action form