users@javaserverfaces.java.net

Re: UISelectItems with Model Bean

From: Imre Oßwald <io_at_mx.jevelopers.com>
Date: Sun, 16 Sep 2007 11:54:32 +0200

Hi,

you should put the bean (or at least the selectitems) into another
scope, probably some kind of page/flash/conversation or into session.

Doesn't show Detail depend on the selected value in the
selectOneMenu? If not you might have luck with setting
immediate="true" on the actionButton and then "fast-forwarding" to
the new view.

Imre

On 14.09.2007, at 13:10, Gurkan Erdogdu wrote:

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: users-
> help_at_javaserverfaces.dev.java.net
>