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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:35:34+00:00 2026-06-09T04:35:34+00:00

Im having some problem with DropDownChoice. I have an Enum with a list of

  • 0

Im having some problem with DropDownChoice.
I have an Enum with a list of school title like:

public enum StudyTitle {

    NONE(null,null),ELEMENTARY("1","Elementary"),COLLEGE("2","College");

    private String code;
    private String description;

    private StudyTitle(String code, String description){
        setCode(code);
        setDescription(description);
    }

    [setter and getter]

}

Then I have a Pojo with a String proprerty call “studyTitleCode” where I want to put the code (ex 1 for elementary, 2 for college etc…).

When I create a DropDownChoice Wicket doesn’t allow me to have a proprerty Model of type String if the DropDownChoice is of type StudyTitle.

Ex.
[building the listOfStudyTitle as ArrayList of Enums]

DropDownChoice<String> studyLevel = new DropDownChoice<String>("id",new PropertyModel<String>(myPojo,"studyTitleCode"),listOfStudyTitle,new ChoiceRenderer<StudyTitle>("description","code"));

Is there a Method to allow Wicket to link one property of the Enum to the Property of Model?

Thanks

  • 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-09T04:35:35+00:00Added an answer on June 9, 2026 at 4:35 am

    The choice options for an AbstractSingleSelectChoice must match the type of the value model. The only related config option for the DropDownChoice that I’m aware of is the IChoiceRenderer which allows you to set how the enum value is rendered (vs the default call toString()).

    One option would be, instead of using the enum instance itself for your choices model, give the enum a String property that can be used:

    public enum TestEnum {
        ONE ("ONE"),
        TWO ("TWO"), 
        THREE ("THREE");
    
        private String value;
    
        TestEnum(String value) {
            this.value = value;
        }
    
        public String getValue() {
            return value;
        }
    
        public static List<String> getStringValues()
        {
            List<String> stringValues = new ArrayList<String>();
            for (TestEnum test : values()) {
                stringValues.add(test.getValue());
            }
    
            return stringValues;
        }
    }
    
    @Override
    protected void onInitialize() {
        super.onInitialize();
    
        IModel<String> myStringValueModel = new Model<String>();
        add(new DropDownChoice<String>("id", myStringValueModel, TestEnum.getStringValues()));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a website and having some problem. if the HTML code is like:
I have been having some problem with the stringByAddingPercentEscapesUsingEncoding: method. Here's what happens: When
i having some problem with TList and BinarySearch. I have this structure: PDoubleEstr =
I'm having some problem using multiple selectBooleanCheckBox in multiple DataTables in ui:repeat. Something like
I'm having some problem with logic of the comparison of some periods. I have
I am having some problem using the clone function in jQuery. I have been
Hello I seem to be having some problem involving counting in Django. I have
I am having some problem installing MySQL in snow leopard. I also have these
I am having some strange problem. I have written a small module in VC++
I'm having some problem with validations for multiple fields, specifically with case-sensitive unique validations

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.