RE: StringResourceModel - how to pass method call instead of bean

2008-02-12 Thread Roland Huss


Michael Mehrle wrote:
 
 Now, if I want to call a method that returns a String instead, like
 so...
 
 add(new Label(greetings, new StringResourceModel(label.allAlbums,
 this, new Model(getTotalAlbums(;
 ^^^
 
 ...with my properties file having this entry:
 
 label.getTotalAlbums = All Albums: ${someReference}
 
 Obviously, this doesn't work, since the new Model(xxx) call expects a
 bean to be passed in. How can I do this with a simple method call? And
 what would my someReference var be?
 

Why dont you simple use MessageFormat's parameter substitution as desribed
in the JavaDoc, i.e.

 .. new StringResourceModel(label.getTotalAlbums,this,null,new Object[] {
getTotalAlbums() });

with 

label.getTotalAlbums=All Albums: ${0}

Alternatively, I you need late binding put 

new AbstractReadOnlyModel() {
public Object getObject() { return getTotalAlbums(); }
}

in the object array (instead of getTotalAlbums() directly)

bye ...

...roland
-- 
View this message in context: 
http://www.nabble.com/TabbedPanel-and-model-load...-tp15385787p15440668.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: StringResourceModel - how to pass method call instead of bean

2008-02-12 Thread Michael Mehrle
Wow, that is cool - excellent, excellent input - that's exactly what I
need. Roland - you're the man :-)

Thanks!

Michael

-Original Message-
From: Roland Huss [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 12, 2008 12:19 PM
To: users@wicket.apache.org
Subject: RE: StringResourceModel - how to pass method call instead of
bean



Michael Mehrle wrote:
 
 One more question - what do you refer to with 'late binding' - I
assume
 the value would be computed 'late' in the process? Please elaborate or
 send me a pointer.
 ...
 
 Alternatively, I you need late binding put 
 
 new AbstractReadOnlyModel() {
public Object getObject() { return getTotalAlbums(); }
 }
 
 

You got it. ('late binding' is probably the wrong synonym here, but it's
a
good metaphor anyway. 
At least for me ;-) Instead of showing only the number of total albums
which
existed 
at creation time of your component, by using this extra indirection step
you
get
your method evaluated each time the component is rendered (which can
happen
quite later 
when your album collection changes, e.g. when you use this label on a
page
where you
manage your stuff).

...roland
-- 
View this message in context:
http://www.nabble.com/TabbedPanel-and-model-load...-tp15385787p15441970.
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]


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



RE: StringResourceModel - how to pass method call instead of bean

2008-02-12 Thread Roland Huss


Michael Mehrle wrote:
 
 One more question - what do you refer to with 'late binding' - I assume
 the value would be computed 'late' in the process? Please elaborate or
 send me a pointer.
 ...
 
 Alternatively, I you need late binding put 
 
 new AbstractReadOnlyModel() {
public Object getObject() { return getTotalAlbums(); }
 }
 
 

You got it. ('late binding' is probably the wrong synonym here, but it's a
good metaphor anyway. 
At least for me ;-) Instead of showing only the number of total albums which
existed 
at creation time of your component, by using this extra indirection step you
get
your method evaluated each time the component is rendered (which can happen
quite later 
when your album collection changes, e.g. when you use this label on a page
where you
manage your stuff).

...roland
-- 
View this message in context: 
http://www.nabble.com/TabbedPanel-and-model-load...-tp15385787p15441970.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: StringResourceModel - how to pass method call instead of bean

2008-02-12 Thread Michael Mehrle
Well, the reason why was I didn't know that call existed ;-) Of course I
looked at the JavaDoc, but the examples there didn't show this scenario.
Thanks a LOT for your reply - this addresses exactly what I'm looking
for :-)

One more question - what do you refer to with 'late binding' - I assume
the value would be computed 'late' in the process? Please elaborate or
send me a pointer.

Michael


** 

Why dont you simple use MessageFormat's parameter substitution as
desribed
in the JavaDoc, i.e.

 .. new StringResourceModel(label.getTotalAlbums,this,null,new
Object[] {
getTotalAlbums() });

with 

label.getTotalAlbums=All Albums: ${0}

Alternatively, I you need late binding put 

new AbstractReadOnlyModel() {
public Object getObject() { return getTotalAlbums(); }
}

in the object array (instead of getTotalAlbums() directly)

bye ...

...roland
-- 
View this message in context:
http://www.nabble.com/TabbedPanel-and-model-load...-tp15385787p15440668.
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]


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



RE: StringResourceModel - how to pass method call instead of bean

2008-02-12 Thread Michael Mehrle
Didn't see a response - does anyone know how to do this?

-Original Message-
From: Michael Mehrle [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 11, 2008 5:53 PM
To: users@wicket.apache.org
Subject: StringResourceModel - how to pass method call instead of bean

I actually have a follow up question regarding StringResourceModel - the
tutorial shows this example, which makes sense:

add(new Label(greetings, new StringResourceModel(label.greetings,
this, new Model(user;

Now, if I want to call a method that returns a String instead, like
so...

add(new Label(greetings, new StringResourceModel(label.allAlbums,
this, new Model(getTotalAlbums(;
^^^

...with my properties file having this entry:

label.getTotalAlbums = All Albums: ${someReference}

Obviously, this doesn't work, since the new Model(xxx) call expects a
bean to be passed in. How can I do this with a simple method call? And
what would my someReference var be?

Hope this makes sense - I just want to avoid passing in/creating a bean.

Michael


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of James Carman
Sent: Monday, February 11, 2008 12:04 PM
To: users@wicket.apache.org
Subject: Re: TabbedPanel tab names

Oops.  That's what I meant. I had to use StringResourceModel in my
case because I had to supply parameters.

On 2/11/08, Igor Vaynberg [EMAIL PROTECTED] wrote:
 or just ResourceModel

 -igor


 On Feb 11, 2008 11:59 AM, James Carman [EMAIL PROTECTED]
wrote:
  Have you tried StringResourceModel?
 
 
  On 2/11/08, Michael Mehrle [EMAIL PROTECTED] wrote:
   Assuming the typical tabbed panel example below - is there a good
way to
   grab the tab name from the page's properties file? What I need to
do is
   to internationalize the tab name. I guess I could do my own call
to grab
   it from the classpath + the property file name. Was hoping
  
   List tabs = new ArrayList();
   tabs.add(new AbstractTab(new Model(first tab))
   { ^^
   public Panel getPanel(String panelId)
   {
   return new TabPanel1(panelId);
   }
   });
  
  
-
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

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



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


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


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