[nbj2ee] Re: JSF showing values in
  • From: Antonio Varela < >
  • To:
  • Subject: [nbj2ee] Re: JSF showing values in <h:selectOneMenu
  • Date: Sat, 29 Sep 2012 10:52:25 -0700

For fixed values you could easily build the options list on the backing bean:

private SelectItem[] animals = new SelectItem[] {

};

On Fri, Sep 28, 2012 at 11:32 AM, karinh 
< >
 wrote:
> Hey Everyone,
>
>
> im having a little trouble with this project im working on with jsf. it's 
> probably not so difficult but im not seeing the right answer.
>
> on the index.xhtml page i want to show a dropdown box with the values i 
> initialized in the faces-config file.
>
> as an example
> faces-config:
>
> Code:
> <property-name>animals</property-name>
>     <list-entries>
>         <value>Cat</value>
>         <value>Dog</value>
>     </list-entries>
>
>
>
> index.xhtml:
>
> Code:
> <h:selectOneMenu id="animal" value="#{myBean.animal}">
>                 <f:selectItems value="#{myBean.animals}"></f:selectItems>
>             </h:selectOneMenu>
>
>
>
> MyBean:
>
> Code:
>  private String animal;
>     private List<SelectItem> animals;
>
>  public void setAnimals(List<String> items) {
>     animals = new ArrayList<SelectItem>();
>     for (String item : items){
>       animals.add(new SelectItem(item));
>     }
>   }
>     public List<SelectItem> getAnimals() {
>
>         return animals;
>     }
>
>
>
>
> this is not showing the values in the dropdown box.
> and i do not know what i have forgotten.
> thanks in advance
>
> Karin
>
>
>
>



-- 
Antonio Varela



[nbj2ee] JSF showing values in <h:selectOneMenu

karinh 09/28/2012

[nbj2ee] Re: JSF showing values in <h:selectOneMenu

Rick Fincher 09/29/2012

[nbj2ee] JSF showing values in <h:selectOneMenu

karinh 09/29/2012

[nbj2ee] Re: JSF showing values in <h:selectOneMenu

Rick Fincher 09/30/2012

[nbj2ee] Re: JSF showing values in <h:selectOneMenu

Antonio Varela 09/29/2012

[nbj2ee] Re: JSF showing values in <h:selectOneMenu

Antonio Varela 09/29/2012

[nbj2ee] JSF showing values in <h:selectOneMenu

karinh 09/29/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close