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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:02:16+00:00 2026-05-11T06:02:16+00:00

I’m new to Wicket and was trying the following configuration: class User { private

  • 0

I’m new to Wicket and was trying the following configuration:

class User {    private String password;     ...     public void setPassword(String password) {      this.password = MD5.encode(password);    }    ... } 

After trying to use the following to bind to the password and finding out that the default implementation of PropertyModel is by default to bound to the field, not the property (weird name eh?)

add(new PasswordTextField('password', new PropertyModel(user, 'password')); 

Why in the world would they have implemented it this way? And is there a PropertyModel alternative that uses getter and setters by default?

Thank you?

  • 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. 2026-05-11T06:02:17+00:00Added an answer on May 11, 2026 at 6:02 am

    PropertyModel will do what you want already. When a PropertyModel is queried for its value, it looks in two places:

    • If a ‘getter’ method exists for the given property, the PropertyModel calls the getter to retrieve the property’s value. Specifically, the PropertyModel looks for a method named get<Property>, where <Property> is the property expression passed to the PropertyModel constructor, and calls the method using reflection if it exists.

    • If no ‘getter’ method exists, the PropertyModel returns the value of the property field directly. Specifically, the PropertyModel uses reflection find a field that matches the property expression passed to the PropertyModel constructor. If a matching field is found, the PropertyModel returns the field’s value. Note that the PropertyModel will check private and protected fields in addition to public fields for a match.

    In your case, the property expression used in the PropertyModel constructor is 'password', so the PropertyModel will first look for a method on the user object called getPassword. If no such method exists, the PropertyModel will return the value of the private password field instead.

    Since in your case the PropertyModel is returning the private field’s value instead of calling the ‘getter’, you most likely mistyped the name of the getter in your User class. For example, f you accidentally typed getPasssword (with 3 s’s), the PropertyModel won’t find it, and will fallback to returning the private field.


    EDIT

    If you don’t like PropertyModel‘s default behavior, you can create a subclass of PropertyModel that will prevent Wicket from trying to read/write to private fields. This way, you can force all property accesses to occur through getters and setters.

    I wrote an example BeanPropertyModel class to demonstrate this:

    import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.model.PropertyModel;  /**  * A custom implementation of {@link org.apache.wicket.model.PropertyModel}  * that can only be bound to properties that have a public getter or setter method.  *   * @author mspross  *  */ public class BeanPropertyModel extends PropertyModel {      public BeanPropertyModel(Object modelObject, String expression) {         super(modelObject, expression);     }      @Override     public Object getObject() {         if(getPropertyGetter() == null)             fail('Missing getter');         return super.getObject();                    }      @Override     public void setObject(Object modelObject) {         if(getPropertySetter() == null)             fail('Missing setter');         super.setObject(modelObject);     }      private void fail(String message) {          throw new WicketRuntimeException(                 String.format('%s. Property expression: '%s', class: '%s'.',                         message,                         getPropertyExpression(),                         getTarget().getClass().getCanonicalName()));     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.