0

I managed to retrieve all the information I need from database, but when I put it in <p:selectOneMenu> using <f:selectItems value=""> I get an empty <p:selectOneMenu>.

enter image description here

This is a snippet of my code :

my xhtml file:

<p:panelGrid columns="2">
    <h:outputLabel for="usernames" value="usernames "/>

    <p:selectOneMenu id="usernames" value="#{Jcalendar.THE_CHOSEN_ONE}">
        <f:selectItems value="Jcalendar.user_spinner_list"/>
    </p:selectOneMenu>
</p:panelGrid>

my JcalendarBeans.java file

@ManagedBean(name = "Jcalendar")
@SessionScoped
public class JcalendarBeans implements Serializable {

    private static final long serialVersionUID = 1L;
    String THE_CHOSEN_ONE;

    public String getTHE_CHOSEN_ONE() {
        return THE_CHOSEN_ONE;
    }

    public void setTHE_CHOSEN_ONE(String tHE_CHOSEN_ONE) {
        THE_CHOSEN_ONE = tHE_CHOSEN_ONE;
    }

    List<JcalendarController> user_spinner_list = new ArrayList<JcalendarController>();

    @PostConstruct
    public void start() {
        user_spinner_list = JcalendarDAO.AllUsarname_spinner();
    }
}

any help would be appropriated

Tiny
  • 27,221
  • 105
  • 339
  • 599
Moodi1409
  • 155
  • 1
  • 10

1 Answers1

1

In your xhtml file make sure you add "()":

 <f:selectItems value="Jcalendar.user_spinner_list()"/>
sasuri
  • 972
  • 3
  • 11
  • 26
  • I get values now but I do not know how to converted to string ? – Moodi1409 Dec 19 '14 at 20:02
  • 2
    This precisely does not appear to be an answer. If that list contains composite/complex objects, you need to explicitly tell JSF to use a specific property as an `itemLabel` and another property as an `itemValue` or you need to use a `java.util.Map` (or `TreeMap`, `LinkedHashMap` depending upon the requirements) in which keys are inferred as option's labels and values are inferred as option's values (in the generated ` – Tiny Dec 20 '14 at 16:03
  • well... this what i did !!! – Moodi1409 Dec 21 '14 at 19:21
  • then public static List AllUsarname_spinner() { } – Moodi1409 Dec 21 '14 at 19:22