Re: ResourceModel vs. getLocalizer

2008-08-19 Thread Erik van Oosten
There is a big difference, the model variant will evaluate during the
render phase. You can not use localization in the constructor of your
component, you can however safely construct a ResourceModel (but not
call getObject on it).

In general, I would use localizer when you need direct access to a
message from code. This should be rare though, most message can be
placed with the wicket:message element.

Regards,
Erik.


Timo Rantalaiho wrote:
 On Mon, 18 Aug 2008, lesterburlap wrote:
   
 new ResourceModel(my.resource.key).getObject().toString();
 or
 getLocalizer().getString(my.resource.key, MyComponent.this);
 

 Isn't the latter same as 

   Component.getString(my.resource.key);

 ?

 And ResourceModel can typically be used directly as the 
 model of the Label displaying the String

   add(new Label(foo, new ResourceModel(my.resource.key)));

   
 I've been using getLocalizer almost everywhere, and only using ResourceModel
 when I'm trying to get a property string during Component construction (to
 avoid those getLocalizer warnings).  But I'm not really sure if my reasoning
 is good...
 

 I wouldn't think that there is any difference. If you are 
 worried about performance, try profiling the application.

 Best wishes,
 Timo
   

--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceModel vs. getLocalizer

2008-08-19 Thread lesterburlap

 you can however safely construct a ResourceModel 
 (but not call getObject on it).

So, doing ResourceModel(key).getObject().getString() is really kind of
silly and defeats the whole purpose of the ResourceModel?

LBB
-- 
View this message in context: 
http://www.nabble.com/ResourceModel-vs.-getLocalizer-tp19040992p19051586.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceModel vs. getLocalizer

2008-08-19 Thread Timo Rantalaiho
On Tue, 19 Aug 2008, Erik van Oosten wrote:
 There is a big difference, the model variant will evaluate during the
 render phase. You can not use localization in the constructor of your

Well, this

  new ResourceModel(my.resource.key).getObject().toString();

will of course evaluate right away (and thus cannot be used 
in a constructor), but as lesterburlap also came to think, 
this is a really weird use of ResourceModel :) What you say 
here

 component, you can however safely construct a ResourceModel (but not
 call getObject on it).

would be the normal way.

Best wishes,
Timo

-- 
Timo Rantalaiho   
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceModel vs. getLocalizer

2008-08-18 Thread Timo Rantalaiho
On Mon, 18 Aug 2008, lesterburlap wrote:
 new ResourceModel(my.resource.key).getObject().toString();
 or
 getLocalizer().getString(my.resource.key, MyComponent.this);

Isn't the latter same as 

  Component.getString(my.resource.key);

?

And ResourceModel can typically be used directly as the 
model of the Label displaying the String

  add(new Label(foo, new ResourceModel(my.resource.key)));

 I've been using getLocalizer almost everywhere, and only using ResourceModel
 when I'm trying to get a property string during Component construction (to
 avoid those getLocalizer warnings).  But I'm not really sure if my reasoning
 is good...

I wouldn't think that there is any difference. If you are 
worried about performance, try profiling the application.

Best wishes,
Timo

-- 
Timo Rantalaiho   
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]