You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Kostas Karadamoglou <ka...@yahoo.gr> on 2005/03/19 12:50:15 UTC

selectOneMenu does not set the selected option

Hi again!

I have a problem with SelectOneMenu, JSF does not set the current 
selection of the user.
this is the jsf tags that I use:

<h:selectOneMenu id="selectCategory" 
value="#{eventHandler.selectedCategory}">
        <f:selectItems id="allCategories" 
value="#{eventHandler.allCategories}"/>
</h:selectOneMenu>

the allCategories returns a list of selectItems which contain 
java.lang.Integer as object. The
selectedCategory is of type int.

While I was debugging the application I 've noticed that JSF does not 
invoke the setter of
selectedCategory.

Do you know how canI solve this problem?

Below I have the getter for each property in the above jsf tags:

    public int getSelectedCategory() {
        return selectedCategory;
    }

    public void setSelectedCategory(int selectedCategory) {
        this.selectedCategory = selectedCategory;
    }

    public List getAllCategories(){
        if(this.allCategories==null){
            this.allCategories=new ArrayList();
            this.allCategories.add(new 
SelectItem(converter.getAsInteger(new Category()),"Choose a category..."));
            List categories=this.eventRegistry.getCategories();
            for(Iterator iter=categories.iterator(); iter.hasNext();){
                Category category=(Category)iter.next();
                this.allCategories.add(new 
SelectItem(converter.getAsInteger(category), category.getTitle()));
            }
        }
        return this.allCategories;
    }

Re: selectOneMenu does not set the selected option

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
Yes it  was the most idiot mistake I have eve done!!!! I lost 1.5 days 
to find the solution!!

Heath Borders wrote:

>You didn't have an <h:form/>?  Man!  your bug was driving me crazy
>there.  I'm glad it finally got resolved.  That explains everything!
>
>I'm going to start a new topic for this problem, to bring light to
>problems like it.
>
>
>On Sun, 20 Mar 2005 17:29:54 +0100, Bruno Aranda <br...@gmail.com> wrote:
>  
>
>>I don't know Kostas... have you tried a valueChangeListener to see if
>>selection is changing? You might try also with an empty jsp with the
>>selectManyCheckbox in the page (including the form tags, I always
>>forget them too ;-)) to see if there is no interference with other
>>elements...
>>
>>Good luck,
>>
>>Bruno
>>
>>On Sun, 20 Mar 2005 13:59:46 +0000, Kostas Karadamoglou
>><ka...@yahoo.gr> wrote:
>>    
>>
>>>Yes Bruno That was my mistake!!!!
>>>Now it works, but only for selectOneMenu
>>>
>>>but not for selectManyCheckBox or selectManyList
>>>my selectManyCheckBox has the following decleration:
>>>
>>><h:form>
>>><h:selectManyCheckbox converter="#{categoryConverter}"
>>>value="#{userHandler.regCategories}">
>>>                   <f:selectItems value="#{eventHandler.categories}"/>
>>>               </h:selectManyCheckbox>>
>>></h:form>
>>>
>>>the userHandler.regCategories is of type List
>>>Do you have any idea why it does not work in the "many" mode?
>>>
>>>thank you in advance, Kostas
>>>
>>>Bruno Aranda wrote:
>>>
>>>      
>>>
>>>>Hi Kostas,
>>>>
>>>>Are your <h:form> tags included in the jsp file?
>>>>
>>>>Bruno
>>>>
>>>>
>>>>On Sat, 19 Mar 2005 14:56:36 +0000, Kostas Karadamoglou
>>>><ka...@yahoo.gr> wrote:
>>>>
>>>>
>>>>        
>>>>
>>>>>I have also done this. String and then parse it. But it doesn't work. I
>>>>>am afraid that the problem is of MyFaces or
>>>>>of wrong configuration :-(
>>>>>
>>>>>Slawek wrote:
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>>>i have never tried int and Interer
>>>>>>but i have tried int and String witht the same result as You
>>>>>>
>>>>>>now im using String and String - current selection is ok
>>>>>>maybe try Integer and Integer
>>>>>>if doesnt help just use String and String + Integer.parseInt() :P
>>>>>>
>>>>>>
>>>>>>Slawek
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>><ka...@yahoo.gr> napisał:
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>>>>
>>>>>>>Hi again!
>>>>>>>
>>>>>>>I have a problem with SelectOneMenu, JSF does not set the current
>>>>>>>selection of the user.
>>>>>>>this is the jsf tags that I use:
>>>>>>>
>>>>>>><h:selectOneMenu id="selectCategory"
>>>>>>>value="#{eventHandler.selectedCategory}">
>>>>>>>       <f:selectItems id="allCategories"
>>>>>>>value="#{eventHandler.allCategories}"/>
>>>>>>></h:selectOneMenu>
>>>>>>>
>>>>>>>the allCategories returns a list of selectItems which contain
>>>>>>>java.lang.Integer as object. The
>>>>>>>selectedCategory is of type int.
>>>>>>>
>>>>>>>While I was debugging the application I 've noticed that JSF does not
>>>>>>>invoke the setter of
>>>>>>>selectedCategory.
>>>>>>>
>>>>>>>Do you know how canI solve this problem?
>>>>>>>
>>>>>>>Below I have the getter for each property in the above jsf tags:
>>>>>>>
>>>>>>>   public int getSelectedCategory() {
>>>>>>>       return selectedCategory;
>>>>>>>   }
>>>>>>>
>>>>>>>   public void setSelectedCategory(int selectedCategory) {
>>>>>>>       this.selectedCategory = selectedCategory;
>>>>>>>   }
>>>>>>>
>>>>>>>   public List getAllCategories(){
>>>>>>>       if(this.allCategories==null){
>>>>>>>           this.allCategories=new ArrayList();
>>>>>>>           this.allCategories.add(new
>>>>>>>SelectItem(converter.getAsInteger(new Category()),"Choose a
>>>>>>>category..."));
>>>>>>>           List categories=this.eventRegistry.getCategories();
>>>>>>>           for(Iterator iter=categories.iterator(); iter.hasNext();){
>>>>>>>               Category category=(Category)iter.next();
>>>>>>>               this.allCategories.add(new
>>>>>>>SelectItem(converter.getAsInteger(category), category.getTitle()));
>>>>>>>           }
>>>>>>>       }
>>>>>>>       return this.allCategories;
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>>
>>>>>>            
>>>>>>
>>>>>          
>>>>>
>>>>
>>>>        
>>>>
>>>      
>>>
>
>
>  
>


Re: selectOneMenu does not set the selected option

Posted by Heath Borders <he...@gmail.com>.
You didn't have an <h:form/>?  Man!  your bug was driving me crazy
there.  I'm glad it finally got resolved.  That explains everything!

I'm going to start a new topic for this problem, to bring light to
problems like it.


On Sun, 20 Mar 2005 17:29:54 +0100, Bruno Aranda <br...@gmail.com> wrote:
> I don't know Kostas... have you tried a valueChangeListener to see if
> selection is changing? You might try also with an empty jsp with the
> selectManyCheckbox in the page (including the form tags, I always
> forget them too ;-)) to see if there is no interference with other
> elements...
> 
> Good luck,
> 
> Bruno
> 
> On Sun, 20 Mar 2005 13:59:46 +0000, Kostas Karadamoglou
> <ka...@yahoo.gr> wrote:
> > Yes Bruno That was my mistake!!!!
> > Now it works, but only for selectOneMenu
> >
> > but not for selectManyCheckBox or selectManyList
> > my selectManyCheckBox has the following decleration:
> >
> > <h:form>
> > <h:selectManyCheckbox converter="#{categoryConverter}"
> > value="#{userHandler.regCategories}">
> >                    <f:selectItems value="#{eventHandler.categories}"/>
> >                </h:selectManyCheckbox>>
> > </h:form>
> >
> > the userHandler.regCategories is of type List
> > Do you have any idea why it does not work in the "many" mode?
> >
> > thank you in advance, Kostas
> >
> > Bruno Aranda wrote:
> >
> > >Hi Kostas,
> > >
> > >Are your <h:form> tags included in the jsp file?
> > >
> > >Bruno
> > >
> > >
> > >On Sat, 19 Mar 2005 14:56:36 +0000, Kostas Karadamoglou
> > ><ka...@yahoo.gr> wrote:
> > >
> > >
> > >>I have also done this. String and then parse it. But it doesn't work. I
> > >>am afraid that the problem is of MyFaces or
> > >>of wrong configuration :-(
> > >>
> > >>Slawek wrote:
> > >>
> > >>
> > >>
> > >>>i have never tried int and Interer
> > >>>but i have tried int and String witht the same result as You
> > >>>
> > >>>now im using String and String - current selection is ok
> > >>>maybe try Integer and Integer
> > >>>if doesnt help just use String and String + Integer.parseInt() :P
> > >>>
> > >>>
> > >>>Slawek
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>><ka...@yahoo.gr> napisał:
> > >>>
> > >>>
> > >>>
> > >>>>Hi again!
> > >>>>
> > >>>>I have a problem with SelectOneMenu, JSF does not set the current
> > >>>>selection of the user.
> > >>>>this is the jsf tags that I use:
> > >>>>
> > >>>><h:selectOneMenu id="selectCategory"
> > >>>>value="#{eventHandler.selectedCategory}">
> > >>>>        <f:selectItems id="allCategories"
> > >>>>value="#{eventHandler.allCategories}"/>
> > >>>></h:selectOneMenu>
> > >>>>
> > >>>>the allCategories returns a list of selectItems which contain
> > >>>>java.lang.Integer as object. The
> > >>>>selectedCategory is of type int.
> > >>>>
> > >>>>While I was debugging the application I 've noticed that JSF does not
> > >>>>invoke the setter of
> > >>>>selectedCategory.
> > >>>>
> > >>>>Do you know how canI solve this problem?
> > >>>>
> > >>>>Below I have the getter for each property in the above jsf tags:
> > >>>>
> > >>>>    public int getSelectedCategory() {
> > >>>>        return selectedCategory;
> > >>>>    }
> > >>>>
> > >>>>    public void setSelectedCategory(int selectedCategory) {
> > >>>>        this.selectedCategory = selectedCategory;
> > >>>>    }
> > >>>>
> > >>>>    public List getAllCategories(){
> > >>>>        if(this.allCategories==null){
> > >>>>            this.allCategories=new ArrayList();
> > >>>>            this.allCategories.add(new
> > >>>>SelectItem(converter.getAsInteger(new Category()),"Choose a
> > >>>>category..."));
> > >>>>            List categories=this.eventRegistry.getCategories();
> > >>>>            for(Iterator iter=categories.iterator(); iter.hasNext();){
> > >>>>                Category category=(Category)iter.next();
> > >>>>                this.allCategories.add(new
> > >>>>SelectItem(converter.getAsInteger(category), category.getTitle()));
> > >>>>            }
> > >>>>        }
> > >>>>        return this.allCategories;
> > >>>>    }
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >
> > >
> > >
> >
> >
> 


-- 
-Heath Borders-Wing
hborders@mail.win.org

Re: selectOneMenu does not set the selected option

Posted by Bruno Aranda <br...@gmail.com>.
I don't know Kostas... have you tried a valueChangeListener to see if
selection is changing? You might try also with an empty jsp with the
selectManyCheckbox in the page (including the form tags, I always
forget them too ;-)) to see if there is no interference with other
elements...

Good luck,

Bruno


On Sun, 20 Mar 2005 13:59:46 +0000, Kostas Karadamoglou
<ka...@yahoo.gr> wrote:
> Yes Bruno That was my mistake!!!!
> Now it works, but only for selectOneMenu
> 
> but not for selectManyCheckBox or selectManyList
> my selectManyCheckBox has the following decleration:
> 
> <h:form>
> <h:selectManyCheckbox converter="#{categoryConverter}"
> value="#{userHandler.regCategories}">
>                    <f:selectItems value="#{eventHandler.categories}"/>
>                </h:selectManyCheckbox>>
> </h:form>
> 
> the userHandler.regCategories is of type List
> Do you have any idea why it does not work in the "many" mode?
> 
> thank you in advance, Kostas
> 
> Bruno Aranda wrote:
> 
> >Hi Kostas,
> >
> >Are your <h:form> tags included in the jsp file?
> >
> >Bruno
> >
> >
> >On Sat, 19 Mar 2005 14:56:36 +0000, Kostas Karadamoglou
> ><ka...@yahoo.gr> wrote:
> >
> >
> >>I have also done this. String and then parse it. But it doesn't work. I
> >>am afraid that the problem is of MyFaces or
> >>of wrong configuration :-(
> >>
> >>Slawek wrote:
> >>
> >>
> >>
> >>>i have never tried int and Interer
> >>>but i have tried int and String witht the same result as You
> >>>
> >>>now im using String and String - current selection is ok
> >>>maybe try Integer and Integer
> >>>if doesnt help just use String and String + Integer.parseInt() :P
> >>>
> >>>
> >>>Slawek
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>><ka...@yahoo.gr> napisał:
> >>>
> >>>
> >>>
> >>>>Hi again!
> >>>>
> >>>>I have a problem with SelectOneMenu, JSF does not set the current
> >>>>selection of the user.
> >>>>this is the jsf tags that I use:
> >>>>
> >>>><h:selectOneMenu id="selectCategory"
> >>>>value="#{eventHandler.selectedCategory}">
> >>>>        <f:selectItems id="allCategories"
> >>>>value="#{eventHandler.allCategories}"/>
> >>>></h:selectOneMenu>
> >>>>
> >>>>the allCategories returns a list of selectItems which contain
> >>>>java.lang.Integer as object. The
> >>>>selectedCategory is of type int.
> >>>>
> >>>>While I was debugging the application I 've noticed that JSF does not
> >>>>invoke the setter of
> >>>>selectedCategory.
> >>>>
> >>>>Do you know how canI solve this problem?
> >>>>
> >>>>Below I have the getter for each property in the above jsf tags:
> >>>>
> >>>>    public int getSelectedCategory() {
> >>>>        return selectedCategory;
> >>>>    }
> >>>>
> >>>>    public void setSelectedCategory(int selectedCategory) {
> >>>>        this.selectedCategory = selectedCategory;
> >>>>    }
> >>>>
> >>>>    public List getAllCategories(){
> >>>>        if(this.allCategories==null){
> >>>>            this.allCategories=new ArrayList();
> >>>>            this.allCategories.add(new
> >>>>SelectItem(converter.getAsInteger(new Category()),"Choose a
> >>>>category..."));
> >>>>            List categories=this.eventRegistry.getCategories();
> >>>>            for(Iterator iter=categories.iterator(); iter.hasNext();){
> >>>>                Category category=(Category)iter.next();
> >>>>                this.allCategories.add(new
> >>>>SelectItem(converter.getAsInteger(category), category.getTitle()));
> >>>>            }
> >>>>        }
> >>>>        return this.allCategories;
> >>>>    }
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> >
> 
>

Re: selectOneMenu does not set the selected option

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
Yes Bruno That was my mistake!!!!
Now it works, but only for selectOneMenu

but not for selectManyCheckBox or selectManyList
my selectManyCheckBox has the following decleration:

<h:form>
<h:selectManyCheckbox converter="#{categoryConverter}" 
value="#{userHandler.regCategories}">
                    <f:selectItems value="#{eventHandler.categories}"/>
                </h:selectManyCheckbox>>
</h:form>

the userHandler.regCategories is of type List
Do you have any idea why it does not work in the "many" mode?

thank you in advance, Kostas

Bruno Aranda wrote:

>Hi Kostas,
>
>Are your <h:form> tags included in the jsp file? 
>
>Bruno
>
>
>On Sat, 19 Mar 2005 14:56:36 +0000, Kostas Karadamoglou
><ka...@yahoo.gr> wrote:
>  
>
>>I have also done this. String and then parse it. But it doesn't work. I
>>am afraid that the problem is of MyFaces or
>>of wrong configuration :-(
>>
>>Slawek wrote:
>>
>>    
>>
>>>i have never tried int and Interer
>>>but i have tried int and String witht the same result as You
>>>
>>>now im using String and String - current selection is ok
>>>maybe try Integer and Integer
>>>if doesnt help just use String and String + Integer.parseInt() :P
>>>
>>>
>>>Slawek
>>>
>>>
>>>
>>>
>>>
>>>
>>><ka...@yahoo.gr> napisał:
>>>
>>>      
>>>
>>>>Hi again!
>>>>
>>>>I have a problem with SelectOneMenu, JSF does not set the current
>>>>selection of the user.
>>>>this is the jsf tags that I use:
>>>>
>>>><h:selectOneMenu id="selectCategory"
>>>>value="#{eventHandler.selectedCategory}">
>>>>        <f:selectItems id="allCategories"
>>>>value="#{eventHandler.allCategories}"/>
>>>></h:selectOneMenu>
>>>>
>>>>the allCategories returns a list of selectItems which contain
>>>>java.lang.Integer as object. The
>>>>selectedCategory is of type int.
>>>>
>>>>While I was debugging the application I 've noticed that JSF does not
>>>>invoke the setter of
>>>>selectedCategory.
>>>>
>>>>Do you know how canI solve this problem?
>>>>
>>>>Below I have the getter for each property in the above jsf tags:
>>>>
>>>>    public int getSelectedCategory() {
>>>>        return selectedCategory;
>>>>    }
>>>>
>>>>    public void setSelectedCategory(int selectedCategory) {
>>>>        this.selectedCategory = selectedCategory;
>>>>    }
>>>>
>>>>    public List getAllCategories(){
>>>>        if(this.allCategories==null){
>>>>            this.allCategories=new ArrayList();
>>>>            this.allCategories.add(new
>>>>SelectItem(converter.getAsInteger(new Category()),"Choose a
>>>>category..."));
>>>>            List categories=this.eventRegistry.getCategories();
>>>>            for(Iterator iter=categories.iterator(); iter.hasNext();){
>>>>                Category category=(Category)iter.next();
>>>>                this.allCategories.add(new
>>>>SelectItem(converter.getAsInteger(category), category.getTitle()));
>>>>            }
>>>>        }
>>>>        return this.allCategories;
>>>>    }
>>>>
>>>>        
>>>>
>>>
>>>      
>>>
>>    
>>
>
>  
>


Re: selectOneMenu does not set the selected option

Posted by Bruno Aranda <br...@gmail.com>.
Hi Kostas,

Are your <h:form> tags included in the jsp file? 

Bruno


On Sat, 19 Mar 2005 14:56:36 +0000, Kostas Karadamoglou
<ka...@yahoo.gr> wrote:
> I have also done this. String and then parse it. But it doesn't work. I
> am afraid that the problem is of MyFaces or
> of wrong configuration :-(
> 
> Slawek wrote:
> 
> > i have never tried int and Interer
> > but i have tried int and String witht the same result as You
> >
> > now im using String and String - current selection is ok
> > maybe try Integer and Integer
> > if doesnt help just use String and String + Integer.parseInt() :P
> >
> >
> > Slawek
> >
> >
> >
> >
> >
> >
> > <ka...@yahoo.gr> napisał:
> >
> >> Hi again!
> >>
> >> I have a problem with SelectOneMenu, JSF does not set the current
> >> selection of the user.
> >> this is the jsf tags that I use:
> >>
> >> <h:selectOneMenu id="selectCategory"
> >> value="#{eventHandler.selectedCategory}">
> >>         <f:selectItems id="allCategories"
> >> value="#{eventHandler.allCategories}"/>
> >> </h:selectOneMenu>
> >>
> >> the allCategories returns a list of selectItems which contain
> >> java.lang.Integer as object. The
> >> selectedCategory is of type int.
> >>
> >> While I was debugging the application I 've noticed that JSF does not
> >> invoke the setter of
> >> selectedCategory.
> >>
> >> Do you know how canI solve this problem?
> >>
> >> Below I have the getter for each property in the above jsf tags:
> >>
> >>     public int getSelectedCategory() {
> >>         return selectedCategory;
> >>     }
> >>
> >>     public void setSelectedCategory(int selectedCategory) {
> >>         this.selectedCategory = selectedCategory;
> >>     }
> >>
> >>     public List getAllCategories(){
> >>         if(this.allCategories==null){
> >>             this.allCategories=new ArrayList();
> >>             this.allCategories.add(new
> >> SelectItem(converter.getAsInteger(new Category()),"Choose a
> >> category..."));
> >>             List categories=this.eventRegistry.getCategories();
> >>             for(Iterator iter=categories.iterator(); iter.hasNext();){
> >>                 Category category=(Category)iter.next();
> >>                 this.allCategories.add(new
> >> SelectItem(converter.getAsInteger(category), category.getTitle()));
> >>             }
> >>         }
> >>         return this.allCategories;
> >>     }
> >>
> >
> >
> >
> 
>

Re: selectOneMenu does not set the selected option

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
I have also done this. String and then parse it. But it doesn't work. I 
am afraid that the problem is of MyFaces or
of wrong configuration :-(

Slawek wrote:

> i have never tried int and Interer
> but i have tried int and String witht the same result as You
>
> now im using String and String - current selection is ok
> maybe try Integer and Integer
> if doesnt help just use String and String + Integer.parseInt() :P
>
>
> Slawek
>
>
>
>
>
>
> <ka...@yahoo.gr> napisał:
>
>> Hi again!
>>
>> I have a problem with SelectOneMenu, JSF does not set the current 
>> selection of the user.
>> this is the jsf tags that I use:
>>
>> <h:selectOneMenu id="selectCategory" 
>> value="#{eventHandler.selectedCategory}">
>>         <f:selectItems id="allCategories" 
>> value="#{eventHandler.allCategories}"/>
>> </h:selectOneMenu>
>>
>> the allCategories returns a list of selectItems which contain 
>> java.lang.Integer as object. The
>> selectedCategory is of type int.
>>
>> While I was debugging the application I 've noticed that JSF does not 
>> invoke the setter of
>> selectedCategory.
>>
>> Do you know how canI solve this problem?
>>
>> Below I have the getter for each property in the above jsf tags:
>>
>>     public int getSelectedCategory() {
>>         return selectedCategory;
>>     }
>>
>>     public void setSelectedCategory(int selectedCategory) {
>>         this.selectedCategory = selectedCategory;
>>     }
>>
>>     public List getAllCategories(){
>>         if(this.allCategories==null){
>>             this.allCategories=new ArrayList();
>>             this.allCategories.add(new 
>> SelectItem(converter.getAsInteger(new Category()),"Choose a 
>> category..."));
>>             List categories=this.eventRegistry.getCategories();
>>             for(Iterator iter=categories.iterator(); iter.hasNext();){
>>                 Category category=(Category)iter.next();
>>                 this.allCategories.add(new 
>> SelectItem(converter.getAsInteger(category), category.getTitle()));
>>             }
>>         }
>>         return this.allCategories;
>>     }
>>
>
>
>


Re: selectOneMenu does not set the selected option

Posted by Slawek <ss...@o2.pl>.
i have never tried int and Interer
but i have tried int and String witht the same result as You

now im using String and String - current selection is ok
maybe try Integer and Integer
if doesnt help just use String and String + Integer.parseInt() :P


Slawek






<ka...@yahoo.gr> napisał:

> Hi again!
>
> I have a problem with SelectOneMenu, JSF does not set the current 
> selection of the user.
> this is the jsf tags that I use:
>
> <h:selectOneMenu id="selectCategory" 
> value="#{eventHandler.selectedCategory}">
>         <f:selectItems id="allCategories" 
> value="#{eventHandler.allCategories}"/>
> </h:selectOneMenu>
>
> the allCategories returns a list of selectItems which contain 
> java.lang.Integer as object. The
> selectedCategory is of type int.
>
> While I was debugging the application I 've noticed that JSF does not 
> invoke the setter of
> selectedCategory.
>
> Do you know how canI solve this problem?
>
> Below I have the getter for each property in the above jsf tags:
>
>     public int getSelectedCategory() {
>         return selectedCategory;
>     }
>
>     public void setSelectedCategory(int selectedCategory) {
>         this.selectedCategory = selectedCategory;
>     }
>
>     public List getAllCategories(){
>         if(this.allCategories==null){
>             this.allCategories=new ArrayList();
>             this.allCategories.add(new 
> SelectItem(converter.getAsInteger(new Category()),"Choose a 
> category..."));
>             List categories=this.eventRegistry.getCategories();
>             for(Iterator iter=categories.iterator(); iter.hasNext();){
>                 Category category=(Category)iter.next();
>                 this.allCategories.add(new 
> SelectItem(converter.getAsInteger(category), category.getTitle()));
>             }
>         }
>         return this.allCategories;
>     }
>



Re: selectOneMenu does not set the selected option

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
The selectOneMenu seems that doesn't keep track the selection of the user

I retried with the getter of selectedCategory as java.lang.Integer. Now 
JSF returns as a selection
an  unknown object !!! (I checked it with Netbean's debugger) with value 
null

Can anyone help me with this problem ? It is very important for me to 
solve it
Kostas Karadamoglou wrote:

> Hi again!
>
> I have a problem with SelectOneMenu, JSF does not set the current 
> selection of the user.
> this is the jsf tags that I use:
>
> <h:selectOneMenu id="selectCategory" 
> value="#{eventHandler.selectedCategory}">
>        <f:selectItems id="allCategories" 
> value="#{eventHandler.allCategories}"/>
> </h:selectOneMenu>
>
> the allCategories returns a list of selectItems which contain 
> java.lang.Integer as object. The
> selectedCategory is of type int.
>
> While I was debugging the application I 've noticed that JSF does not 
> invoke the setter of
> selectedCategory.
>
> Do you know how canI solve this problem?
>
> Below I have the getter for each property in the above jsf tags:
>
>    public int getSelectedCategory() {
>        return selectedCategory;
>    }
>
>    public void setSelectedCategory(int selectedCategory) {
>        this.selectedCategory = selectedCategory;
>    }
>
>    public List getAllCategories(){
>        if(this.allCategories==null){
>            this.allCategories=new ArrayList();
>            this.allCategories.add(new 
> SelectItem(converter.getAsInteger(new Category()),"Choose a 
> category..."));
>            List categories=this.eventRegistry.getCategories();
>            for(Iterator iter=categories.iterator(); iter.hasNext();){
>                Category category=(Category)iter.next();
>                this.allCategories.add(new 
> SelectItem(converter.getAsInteger(category), category.getTitle()));
>            }
>        }
>        return this.allCategories;
>    }
>