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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:01+00:00 2026-05-23T14:26:01+00:00

When creating a new item the user does not want to see the null

  • 0

When creating a new item the user does not want to see the null no selection option in the Select-One Menu, but directly an item from the available items. So either to get rid of the null no option or display directly the second element in the dropdown. I tried the attribute hideNoSelection, but it does nothing.
How can I achieve this?

<h:selectOneMenu id="ugroup" value="#{usersController.selected.ugroup}" title="#{bundle.CreateUsersTitle_ugroup}" required="true" requiredMessage="#{bundle.CreateUsersRequiredMessage_ugroup}">

</h:selectOneMenu>

—————-EDIT (after @Balus Answer) ———————
Here is the Utility method that grabs JPA Lists to be displayed as a <h:selectOneMenu /> :

public class JsfUtil {

    public static SelectItem[] getSelectItems(List<?> entities, boolean selectOne) {
        int size = selectOne ? entities.size() + 1 : entities.size();
        SelectItem[] items = new SelectItem[size];
        int i = 0;
        if (selectOne) { // part to be removed
            items[0] = new SelectItem("", "---");
            i++;
        } // end of part to be removed
        for (Object x : entities) {
            items[i++] = new SelectItem(x, x.toString());
        }
        return items;
    }

So appearently, all I have to do is remove this part? :

 if (selectOne) {
                items[0] = new SelectItem("", "---");
                i++;
            }  

But as this static method is used everywhere in my code, would it have any unwanted consequences?

  • Like, when the user wants explicitly a null value from the <h:selectOneMenu />, if he decides to choose no option. My guess was to use <f:selectItem :

  • 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-23T14:26:02+00:00Added an answer on May 23, 2026 at 2:26 pm

    Just ensure that #{ugroupController.itemsAvailableSelectOne} does not contain an item with value null in the array or list. The first item will be the default selected option.

    Alternatively, preset the property behind #{usersController.selected.ugroup} with the value of the desired item during bean’s (post)construction.

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

Sidebar

Related Questions

I am new to creating work item types in TFS and want to create
When creating a new WSPBuilder project or new WSPBuilder item in Visual Studio, you
I have 2 custom fields in my WordPress system when creating new posts. One
I'm creating a program where the user has the option of creating their own
I'm creating a catalog/collection ios4 application. One element of the app lets the user
I have a popup menu and I want one of the items to open
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
When I'm creating new project with GWT plug in it creates a skeleton project
I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
Can I avoid third party code from creating new threads, starting new VMs, or

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.