You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sakthi vel <ve...@gmail.com> on 2010/09/12 20:37:25 UTC

Wicket Internalization - Exceptions

Hello,

I want to display a value of label using the concept of
Internationalization.
Actually there are number of property file for different languages.
When I try to add the dynamic field to property file, I am getting an
exception

*WicketMessage: No get method defined for class: class
org.apache.wicket.markup.html.form.Form expression: personName*


Content of files are

*Property files:*
status: Hello ${personName}


*Html file:*
<span wicket:id = "hello"></span>

Model file:

public class NameModel
{
   private String personName;
   public String getPersonName()
   {
    return personName;
   }

   public void setPersonName(String personName)
   {
    this.personName;
   }
}


*Java file:*

NameModel nameModel = new NameModel();
nameModel.setPersonName("Test");

add(new Label("lblProperty", new StringResourceModel("hello", this, new
PropertyModel(nameModel, "personName"))));


Could anyone explain what is the reason for receiving this exception and
steps to overcome this.

Re: Wicket Internalization - Exceptions

Posted by "vela@wav@gmail.com" <ve...@gmail.com>.
Hello,

It is working fine now.

I made a mistake in the html page by referring the property file key for
both the wicket:message & span tags. But in the property file the hello key
is assigned 
hello: Hello ${personName}

So whenever wicket:message is called, it looks for the getPersonName() and
there is no corresponding backing model in the java file. The wicket:message
tag is removed and it is working fine.


Thanks so much for your time & inputs.






-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Internalization-Exceptions-tp2536565p2540276.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Internalization - Exceptions

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Post your code.

On Tue, Sep 14, 2010 at 10:27 AM, vela@wav@gmail.com <ve...@gmail.com>wrote:

>
> Hello again,
>
> I followed the steps but still its throws an exception. It seems it looks
> for property inside the Form. The exception it throws is like this.
>
>
> Page
> [Page class = com.i18n.I18nPage, id = 0, version = 0]:
>
>
> #       Path    Size    Type    Model Object
> 1       frmProperty     1.9K    org.apache.wicket.markup.html.form.Form
> 2       frmProperty:lblProperty         1.9K
> org.apache.wicket.markup.html.basic.Label       Hello Test
>
> When you look in to the exception, the model "Hello Test" is retrieved but
> it still look inside the form for the getter method.
>
> Any ideas on how to overcome would be of great help and kindly explain the
> reasons for the exception.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Internalization-Exceptions-tp2536565p2539145.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Wicket Internalization - Exceptions

Posted by "vela@wav@gmail.com" <ve...@gmail.com>.
Hello again,

I followed the steps but still its throws an exception. It seems it looks
for property inside the Form. The exception it throws is like this.


Page
[Page class = com.i18n.I18nPage, id = 0, version = 0]:

 
#	Path	Size	Type	Model Object
1   	frmProperty   	1.9K   	org.apache.wicket.markup.html.form.Form   	   
2   	frmProperty:lblProperty   	1.9K   
org.apache.wicket.markup.html.basic.Label   	Hello Test

When you look in to the exception, the model "Hello Test" is retrieved but
it still look inside the form for the getter method.

Any ideas on how to overcome would be of great help and kindly explain the
reasons for the exception.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Internalization-Exceptions-tp2536565p2539145.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Internalization - Exceptions

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Some comments are inline in your code....

On Mon, Sep 13, 2010 at 4:09 AM, vela@wav@gmail.com <ve...@gmail.com>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

Re: Wicket Internalization - Exceptions

Posted by "vela@wav@gmail.com" <ve...@gmail.com>.
Hello,

Here is the exact code of the Jave Page class

public class I18nPage extends WebPage
{
	private Form frmProperty;
	private Label lblProperty;
	
	public I18nPage()
	{
		frmProperty = new Form("frmProperty");
		add(frmProperty);
		
		NameModel nameModel = new NameModel();
		nameModel.setPersonName("sakthi");
		
		lblProperty = new Label("lblProperty",new StringResourceModel("hello", new
PropertyModel(nameModel, "personName")));
		frmProperty.add(lblProperty);
	}
}
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Internalization-Exceptions-tp2536565p2537105.html
Sent from the Wicket - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Internalization - Exceptions

Posted by Martin Grigorov <mg...@apache.org>.
On Sun, Sep 12, 2010 at 8:37 PM, sakthi vel <ve...@gmail.com> wrote:

> Hello,
>
> I want to display a value of label using the concept of
> Internationalization.
> Actually there are number of property file for different languages.
> When I try to add the dynamic field to property file, I am getting an
> exception
>
> *WicketMessage: No get method defined for class: class
> org.apache.wicket.markup.html.form.Form expression: personName*
>
>
> Content of files are
>
> *Property files:*
> status: Hello ${personName}
>
>
> *Html file:*
> <span wicket:id = "hello"></span>
>
> Model file:
>
> public class NameModel
> {
>   private String personName;
>   public String getPersonName()
>   {
>    return personName;
>   }
>
>   public void setPersonName(String personName)
>   {
>    this.personName;
>   }
> }
>
>
> *Java file:*
>
> NameModel nameModel = new NameModel();
> nameModel.setPersonName("Test");
>
> add(new Label("lblProperty", new StringResourceModel("hello", this, new
> PropertyModel(nameModel, "personName"))));
>
Can you paste the exact code of this file.
According to the exception Wicket looks for property "personName" in a Form,
not in your model.

>
>
> Could anyone explain what is the reason for receiving this exception and
> steps to overcome this.
>