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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:23:28+00:00 2026-05-20T18:23:28+00:00

This drives me crazy, cannot find the error. Here the xhtml page: … <h:selectManyListbox

  • 0

This drives me crazy, cannot find the error.

Here the xhtml page:

...
<h:selectManyListbox style="width: 207px" size="10" value="#{reportBean.selectedSeverities}">
                            <f:selectItems value="#{reportBean.severities}"/>
                        </h:selectManyListbox>
...

The report Bean:

...
private List<Severity> severities;
private List<Severity> selectedSeverities = new ArrayList<Severity>();
...
public List<Severity> getSeverities() {
   if (this.severities == null) {
        this.severities = new ArrayList<Severity>();
        this.severities.add(Severity.LOW);
        this.severities.add(Severity.HIGH);
        this.severities.add(Severity.UNDEFINED);
        this.severities.add(Severity.MEDIUM);
    }
        return severities;
}

For a command Button I have the following action method:

if (!selectedSeverities.isEmpty()) {
    Severity s = selectedSeverities.get(0);
}
return;

Wenn I select a severity(enum) and hit the commandbutton I get the following stack trace:

...
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to securityscan.util.Severity
...

I don’t get it.

Any help is very apprecieated.

BR Reen

  • 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-20T18:23:29+00:00Added an answer on May 20, 2026 at 6:23 pm

    You can’t use enums in combination with h:selectMany*** components without using a converter. JSF/EL does not see/know the generic type of each of the separate list items. In other words, it only sees a List and not List<Severity> and treats every item as a String, unless you tell it to do otherwise.

    You need to create and specify a converter yourself. For enums, it’s the best to extend the JSF-provided EnumConverter.

    package com.example;
    
    import javax.faces.convert.EnumConverter;
    import javax.faces.convert.FacesConverter;
    
    @FacesConverter(value="severityConverter")
    public class SeverityConverter extends EnumConverter {
    
        public SeverityConverter() {
            super(Severity.class);
        }
    
    }
    

    (note that when you’re still using the old JSF 1.2, you should be declaring this as <converter> in faces-config.xml instead of by @FacesConverter)

    Which you use as follows:

    <h:selectManyListbox converter="severityConverter">
    

    See also:

    • How to use enums in select many menus?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is beyond both making sense and my control. That being said here is
I know this is crazy, but IE can drive one to do crazy things.
How is this achieved? Here it says the java version is: WebDriver driver; //
I have found this example on StackOverflow: var people = new List<Person> { new
I want to use a temp directory that will be unique to this build.
I have a login.jsp page which contains a login form. Once logged in the
I have a Java project that uses this driver for serial communication. The driver
Is there any way to do this? My website is http://kennethreitz.com . Its driven
I have a new web app that is packaged as a WAR as part
(please excuse that I didn't use aliases). I would like my query output to

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.