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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:05:14+00:00 2026-06-11T01:05:14+00:00

I have an issue with the way Wicket searches for the selection for a

  • 0

I have an issue with the way Wicket searches for the selection for a DropDownChoice in a Model.

Example

//User Bean
public class Users {
  private Long language_id;
  public Long getLanguage_id() {
    return language_id;
  }
  public void setLanguage_id(Long language_id) {
    this.language_id = language_id;
  }
}

//Language Bean
public class Language {
  private Long language_id;
  private String name;
  public Long getLanguage_id() {
    return language_id;
  }
  public void setLanguage_id(Long language_id) {
    this.language_id = language_id;
  }
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
}

Wicket HTML

<form wicket:id="form">
  <select wicket:id="language_id"/>
</form>

Jave Code that renders/compiles the Wicket Form:

public class UserForm extends Form<Users> {
  public UserForm(String id, Users user) {
    add(new DropDownChoice<Language>("language_id", Application
      .getBean(LanguageDaoImpl.class).getLanguages(),
      new ChoiceRenderer<Language>("name", "language_id")));
  }
}

The issue is that the rendering works fine, all languages are in the dropdown selection. However as soon as any User is loaded into the form, Wicket will search for a property “language” in the Long value “language_id” and throw some exception like “No get method defined for class: java.lang.Long …”
Wickets expects me to put the full Bean “Language” in the Users object. However I just have the ID in the Users Object and not the full Bean.

How can I make Wicket use simply the ID and not expect the whole object to be available? I guess I need to overwrite some method in the DropDownChoice, but I could not find any suitable.

Thanks!
Sebastian

  • 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-11T01:05:15+00:00Added an answer on June 11, 2026 at 1:05 am

    The problem is that you are trying to set a Language in the field language_id. You need to use an IModel to map the Language to the id. Here’s some working sample code:

    public class UserForm extends Form<Users> {
        public UserForm(String id, final Users user) {
            super(id);
            final List<Language> l = new ArrayList<HomePage.Language>();
            l.add(new Language(1L, "English"));
            l.add(new Language(2L, "German"));
            add(new DropDownChoice<Language>("language_id", new IModel<Language>() {
                public Language getObject() {
                    for (Language lang : l) {
                        if (lang.getLanguage_id().equals(user.getLanguage_id())) {
                            return lang;
                        }
                    }
                    return null;
                }
    
                public void setObject(Language object) {
                    user.setLanguage_id(object.getLanguage_id());
                }
    
                public void detach() {
                }
            }, l, new ChoiceRenderer<Language>("name", "language_id")));
        }
    }
    

    I don’t think it’s possible to just override a method in DropDownChoice because the generic type of it is always the same as the choices list and model type. This means you can’t pass a List<Language> to a DropDownChoice and expect to get a Long back without some model that knows how to convert the values.

    Edit: Another option is to use a DropDownChoice<Long> and implement a custom ChoiceRenderer which knows how to convert the Long to the name of the language. I think that’s the easiest solution in this case.

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

Sidebar

Related Questions

I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I have been trying for hours to find a way to solve the issue,
I have an issue that I have been dealing for way to long Please
I have an issue with my ExternalInterface. The way it is currently set up
I have an issue with a simple program. I'm opening a QFileDialog this way:
I have an issue, i need to add two class members using a operator
I have an issue with window.navigator, I'm getting error code 1, User denied Geolocation
I have an issue, I have data being sent to the user who needs
We have an issue with the way we are creating a Mutex . The
I have an issue with model binding a checkbox from a form to an

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.