Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:21:26+00:00 2026-06-02T02:21:26+00:00

i have a managed bean called Lecturer. Lecturer managed bean includes a relation between

  • 0

i have a managed bean called Lecturer. Lecturer managed bean includes a relation between departments. I want to show all departments stored in the database. when i register a lecturer i need to get its department.

My Lecturer managed bean. i have proper setter and getter methods. i just omit it for clarification.

public class Lecturer 
{

    private String name;
    private String surname;

    private String email;
    private String username;
    private String password;


    private List<Department> departments;

    private LecturerService lecturerService;
    private DepartmentService departmentService;
}

my Licturer.xhtml file:

<h:form>
<f:view>
<p:panelGrid columns="2">  

<f:facet name="header">Lecturer Registration Form</f:facet> 

<h:outputLabel for="name" value="Name :" />  
<p:inputText id="name" value="#{Lecturer.name}" label="Name" required="true" />

<h:outputLabel for="surname" value="Surname :" />  
<p:inputText id="surname" value="#{Lecturer.surname}" label="Surname" required="true" />

<h:outputLabel for="department" value="Department :" /> 


<p:selectOneMenu value="#{Lecturer.departments}" effect="fade" editable="true" var="p" >
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{Lecturer.departments}" var="lec"
itemLabel="#{lec.name}" itemValue="#{lec.name}"/>
</p:selectOneMenu>


<h:outputLabel for="email" value="Email :" />  
<p:inputText id="email" value="#{Lecturer.email}" label="Email" required="true" />

<h:outputLabel for="username" value="User Name :" />  
<p:inputText id="username" value="#{Lecturer.username}" label="Email" required="true" />

<h:outputLabel for="password" value="Password :" />  
<p:inputText id="password" value="#{Lecturer.password}" label="Password" required="true" />

<f:facet name="footer">

 <p:commandButton type="submit"
                id="lecturer"
                action="#{Lecturer.registerLecturer}"
                value="Register" icon="ui-icon-disk">

                </p:commandButton>

</f:facet>

</p:panelGrid>
</f:view>
</h:form>

my faces-config.xml

<managed-bean>
        <managed-bean-name>Lecturer</managed-bean-name>
        <managed-bean-class>com.studinfo.controller.Lecturer</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>

        <managed-property>
            <property-name>departmentService</property-name>
            <property-class>com.studinfo.services.DepartmentService</property-class>
            <value>#{DepartmentService}</value>
        </managed-property>

        <managed-property>
            <property-name>lecturerService</property-name>
            <property-class>com.studinfo.services.LecturerService</property-class>
            <value>#{LecturerService}</value>
        </managed-property>
    </managed-bean>

when i remove the selectOneMenu tag. my page works properly.

any idea about the solution?

Do i must add a converter between string and Department class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:21:28+00:00Added an answer on June 2, 2026 at 2:21 am

    The value attribute of p:selectOneMenu should hold the reference to a single department (this is the selected department) and not the whole list. You need to add a field for this in your bean, e.g.:

    private Department selectedDepartment
    // getter and setter
    

    Then in your facelet change the value attribute of p:selectOneMenu and the f:selectItems:

    <p:selectOneMenu value="#{Lecturer.selectedDepartment}" effect="fade" 
                     editable="true" var="p" >
      <f:selectItem itemLabel="Select One" itemValue="" />
      <f:selectItems value="#{Lecturer.departments}" var="lec"
                     itemLabel="#{lec.name}" itemValue="#{lec}"/>
    </p:selectOneMenu>
    

    Furthermore you will need a converter to map selected strings to objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this managed bean which makes SQL queries to Oracle database and returns
I have this managed bean which takes two values from database's table import java.io.Serializable;
I have a managed bean which makes SQL queries to Oracle database. This is
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
I have a session managed bean called personne and I would like to display
i have an managed bean(session scope) like this: class Home {// as homeBean public
I'm using JSF 2.0. I have a managed bean which I can access through
I am using JSF and spring . I have a spring managed bean in
I have one method in my managed bean which returns javascript as a string.
I have a page that is backed by a ViewScoped Managed Bean. The page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.