users@javaserverfaces.java.net

UISelectItems with Model Bean

From: Gurkan Erdogdu <gurkanerdogdu_at_yahoo.com>
Date: Fri, 14 Sep 2007 04:10:31 -0700 (PDT)

Hi; I have a model bean in scope request name 'comboFiller' with like that class ComboFiller{ List<SelectItem> items; String selected; public List<SelectItem> getItems(){ if(this.items == null){ //I am doing heavy DB operations to fill list items } } public String getSelected(){ } public String showDetail(){ //ge details item return to view id to detail page; } } I am using this bean in my view to set items in the combo box like <h:selectOneMenu value=''> <f:selectItems value="#{comboFiller.items}"/> </h:selectOneMenu> <h:commandButton action="#{comboFiller.showDetail}"/> My problem is that; When the page is first time loading, it loads combo values from the list; this is OK. But whenever I call any method in the bean with action components, JSF Impl creates newly managed bean and call method getItems() every time. For Example: When call showDetail method, I just want to get detail item description from the database, put this info into the some request bean and navigate to the detailed view. I do not want to JSF Impl call the getItems() in this case, because it is useless, it does not required in the new view, and it consumes time. Is there any logic to achieve this? ____________________________________________________________________________________ Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545433