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

  • SEARCH
  • Home
  • 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 8084951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:57:04+00:00 2026-06-05T17:57:04+00:00

I want to have a list box in JSF. I have written a simple

  • 0

I want to have a list box in JSF. I have written a simple code but it does not work. In demo page I see an empty box with out list and in user page I have error.

UserBean.java

@ManagedBean
@SessionScoped   
public class UserBean implements Serializable{
    public String favYear3;//list box

    public String getFavYear3() {
        return favYear3;
    }

    public void setFavYear3(String favYear3) {
        this.favYear3 = favYear3;
    }
    public static class Year{
        public String yearLabel;
        public String yearValue;

        public Year(String yearLabel, String yearValue){
            this.yearLabel = yearLabel;
            this.yearValue = yearValue;
        }

        public String getYearLabel(){
            return yearLabel;
        }

        public String getYearValue(){
            return yearValue;
        }

    }

    public Year[] year3List;

    public Year[] getFavYear3Value() {

        year3List = new Year[3];
        year3List[0] = new Year("Year3 - 2000", "2000");
        year3List[1] = new Year("Year3 - 2010", "2010");
        year3List[2] = new Year("Year3 - 2020", "2020");

        return year3List;
    }

}

demo.xhtml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>first jsf page</title>
</head>
<h:body>
    <h1>JSF 2 check example</h1>

    <h:form>
        <h:selectOneListbox value="#{UserBean.favYear3}">
            <f:selectItems value="#{UserBean.favYear3Value}" var="y"
                itemLabel="#{y.yearLabel}" itemValue="#{y.yearValue}" />
        </h:selectOneListbox>
    </h:form>

</h:body>
</html>

user.xhtml

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>second jsf page</title>
</head>
<h:body>
    <h:outputText value="#{UserBean.favYear3}"/>
</h:body>
</html>

My problem: in demo page I have an empty box.
in user page the error is:

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: javax.el.PropertyNotFoundException: /demo.xhtml @24,55 value="#{UserBean.favYear3}": Target Unreachable, identifier 'UserBean' resolved to null
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)


root cause 

javax.faces.component.UpdateModelException: javax.el.PropertyNotFoundException: /demo.xhtml @24,55 value="#{UserBean.favYear3}": Target Unreachable, identifier 'UserBean' resolved to null
    javax.faces.component.UIInput.updateModel(UIInput.java:848)
    javax.faces.component.UIInput.processUpdates(UIInput.java:730)
    javax.faces.component.UIForm.processUpdates(UIForm.java:268)
    javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1109)
    javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1109)
    javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1218)
    com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:74)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)

What is wrong?

  • 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-05T17:57:06+00:00Added an answer on June 5, 2026 at 5:57 pm

    You have to make your bean reachable/managed. For this, you can either

    annotate it with a CDI (@Named) or a JSF (@ManagedBean) annotation:

    @Named
    @SessionScoped
    public class UserBean implements Serializable{...}
    

    or describe it in the faces-config.xml as a managed-bean like this:

    <managed-bean>
      <managed-bean-name>userBean</managed-bean-name>
      <managed-bean-class>com.example.UserBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that I load a select dropdown box but I want
i have a list box and i want to add a folder/directory to that
I have a multi-select list box. I want to be able to select a
I have a list of names in a box that I want to filter
I want to have a drop down box that has a list of different
I have a list box and I want to associate it with two event
I want to show multiple columns in the list box. I have referred the
I have List box in which I am displaying values at runtime. But i
I have a List box that I want to display a list of objects,
I am working on a project and I want to have a list box

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.