Some comments are inline in your code....
On Mon, Sep 13, 2010 at 4:09 AM, v...@[email protected] <[email protected]>wrote:
NameModel nameModel = new NameModel();
> nameModel.setPersonName("sakthi");
>
What is a NameModel? I just want you to be aware that you don't need a
specific model (implementation of IModel) class for this. This could be a
Person domain object. Or maybe NameModel is part of your domain. But, you
don't need a Wicket IModel named NameModel just for this.
>
> lblProperty = new Label("lblProperty",new
> StringResourceModel("hello", new
> PropertyModel(nameModel, "personName")));
>
Don't use a property model here. The property model is getting the
"personName" property from your model and then trying to call
"getPersonName" on that. (the property model first calls getPersonName, and
returns the result to the StringResourceModel, which then also calls
getPersonName since you have personName in your properties file.
Instead, you could do this:
Person person = new Person();
person.setFirstName("Jeremy");
person.setLastName("Thomerson");
add(new Label("label", new StringResourceModel("hello", new
Model(person))));
Your properties file would look like this:
hello=Hello ${firstName}, ${lastName}
Of course, where I say "new Model", you could (and usually will) be using a
model that is passed into the page that contains the person, etc... If it's
holding a domain object, it is very likely that this will be a
LoadableDetachableModel.
--
Jeremy Thomerson
http://www.wickettraining.com