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 7178247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:52:57+00:00 2026-05-28T16:52:57+00:00

I am using a selectOneMenu in a JSF 2 applicaiton to allow users to

  • 0

I am using a selectOneMenu in a JSF 2 applicaiton to allow users to select a day in a month. For some reason I can’t get the label, “Select Day” to show up. This is what I am doing:

<h:selectOneMenu id="startDay" value="#{bean.day}">       
    <f:selectItem itemLabel="Select Day" itemValue=""/>
    <f:selectItems value="#{bean.days}"/>
</h:selectOneMenu>

The code in the bean is like this:

private int day;
private List<Integer>days;

Which I’m instantiating in a @PostConstruct init method:

days = new LinkedList<Integer>();
for(int i=1; i<=31; i++) {
    days.add(i);            
}

Everything works fine, but the value displayed in “1” and not “Select Day.” I tried different variations on the tags above but nothing works. What am I missing?

EDIT: I also have a similar widget displaying years, which is initialized in the same way but with the loop starting at 2012. Like this:

years = new LinkedList<Integer>();
for(int i=2012; i<=2020; i++) {
    years.add(i);           
}

This works fine, showing “Select Year” as expected. So is the issue with the instantiating loop starting at 1? And if so, what’s the workaround?

  • 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-05-28T16:52:58+00:00Added an answer on May 28, 2026 at 4:52 pm

    Your code looks fine so far. The “problem” as you described will occur if you have preinitialized the <h:selectOneMenu value> with exactly the item value. In your case, most likely you’ve set the value of day to 1 somewhere in your real code. For example,

    private int day = 1; // Instead of default 0.
    

    or

    public Bean() {
        setDay(1);
    }
    

    Etcetera.


    Update: as per your comment:

    I had it this way because I’m using the page both for editing, and entering a new auction and I wanted to make sure that when coming back to the page to enter a new auction, once another auction was edited, we remove the edited auction’s values. But that’s besides the point, I’ll figure out what to do with it.

    Put the bean in the view scope instead of the session scope. The session scope is the wrong scope for input forms. It should be used for session specifid data only, such as the logged-in user, its preferences and so on. See also Communication in JSF2 – Managed bean scopes.

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

Sidebar

Related Questions

I'm using JSF2 and PrimeFaces3. How can I write selectOneMenu that would invoke JSF
Can I get html select option label based on option value <select id=xx> <option
I'm using JSF 2.0 and want to fill a selectOneMenu with the values of
Hi i have created a custom converter in jsf for combo box using h:selectOneMenu,
I am using JSF 2.0 and PrimeFaces. I have a selectOneMenu and a selectManyCheckbox.
I am using Sun JSF-RI 1.2 and having grief with h:SelectOneMenu. The value is
I'm using h:selectOneMenu and I want to get not the ID value, but the
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button

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.