Prime Faces Menu Selector in JSF

1

I am trying to use a PrimeFacesOneMenu selector for my project. Its functionality is as follows: I want to register an object of type Discipline in the DB, hence I need the selector to include an object of type Teacher in the discipline, not to include the data of the object type Teacher. I can not retrieve the name of all the teachers to show in the selector when I make the choice. Any tips ???

<h:outputLabel value="Selecionar um Professor" />
<p:selectOneMenu id="selectedProf" value="#{selectedProf.recuperarTodosProfessores}" label="Select" effect="fold" editable="true" panelStyle="width:250px">
    <f:selectItem itemLabel="Selecionar" itemValue="" />
    <f:selectItems value="#{curs.professor}" />
</p:selectOneMenu>
<p:commandLink value="Adicionar" update="display1" />
<p:outputPanel id="display1" style="width:250px;padding-left: 5px;margin-top: 10px">
    <p:dataList value="#{discip.professor}" var="curso">#{professor}</p:dataList>
</p:outputPanel>

In this case I have to retrieve the list of objects of type Teacher and show in the selector, appearing only the name of the Teacher to select and add in the teacher attribute of the Discipline class.

    
asked by anonymous 05.08.2014 / 21:59

1 answer

1

I think you're confusing a bit, the value attribute of p:selectOneMenu is where the selected teacher is stored and value of f:selectItems is your list of available teachers.

Do not forget to use converter .

I think it would be + or- so your code.

  <p:selectOneMenu id="selectedProf" value="#{curs.professor}" converter="SeuConverter" label="Select" effect="fold" editable="true" panelStyle="width:250px">
    <f:selectItem itemLabel="Selecionar" itemValue="" />
    <f:selectItems value="#{selectedProf.recuperarTodosProfessores}" var="professor" itemLabel="#{professor.nome}" itemValue="#{professor}" />
  </p:selectOneMenu>
    
06.08.2014 / 02:21