JSF Prime Faces Menu Selector

Asked

Viewed 130 times

1

I am trying to use a Primefaces type selector for my project. Its functionality is the following: I want to register an object of the type Discipline in DB, hence I need the selector to include an object of the type Teacher in the discipline, not to effect the inclusion of the data of the object type Teacher. I am unable to recover the name of all teachers to show on the selector when making the choice. Any hint???

<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 rescue the list of objects of the type Teacher and show in the selector, appearing only the name of the Teacher to select and add in the teacher attribute of the class Discipline.

  • Adelino, put this info in the question by asking edit in the post. If you need help formatting we help you. And delete the comment here because it belongs to the question.

  • I added to the question see if something is missing and delete the comments to get cleaner.

1 answer

1

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

Don’t forget to use one converter.

I believe that 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.