You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Mehrle <mi...@ask.com> on 2008/02/11 20:57:52 UTC

TabbedPanel tab names

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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

Posted by Michael Mehrle <mi...@ask.com>.
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:nabble@tichny.org] 
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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


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

Posted by Roland Huss <na...@tichny.org>.

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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

Posted by Michael Mehrle <mi...@ask.com>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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


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

Posted by Roland Huss <na...@tichny.org>.

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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

Posted by Michael Mehrle <mi...@ask.com>.
Didn't see a response - does anyone know how to do this?

-----Original Message-----
From: Michael Mehrle [mailto:michael.mehrle@ask.com] 
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: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com]
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 <ig...@gmail.com> wrote:
> or just ResourceModel
>
> -igor
>
>
> On Feb 11, 2008 11:59 AM, James Carman <ja...@carmanconsulting.com>
wrote:
> > Have you tried StringResourceModel?
> >
> >
> > On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


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


StringResourceModel - how to pass method call instead of bean

Posted by Michael Mehrle <mi...@ask.com>.
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: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com]
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 <ig...@gmail.com> wrote:
> or just ResourceModel
>
> -igor
>
>
> On Feb 11, 2008 11:59 AM, James Carman <ja...@carmanconsulting.com>
wrote:
> > Have you tried StringResourceModel?
> >
> >
> > On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


RE: TabbedPanel tab names

Posted by Michael Mehrle <mi...@ask.com>.
That seems to work - thanks guys! Much cleaner than manually accessing a
resource bundle.

Thanks,

Michael

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com]
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 <ig...@gmail.com> wrote:
> or just ResourceModel
>
> -igor
>
>
> On Feb 11, 2008 11:59 AM, James Carman <ja...@carmanconsulting.com>
wrote:
> > Have you tried StringResourceModel?
> >
> >
> > On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: TabbedPanel tab names

Posted by James Carman <ja...@carmanconsulting.com>.
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 <ig...@gmail.com> wrote:
> or just ResourceModel
>
> -igor
>
>
> On Feb 11, 2008 11:59 AM, James Carman <ja...@carmanconsulting.com> wrote:
> > Have you tried StringResourceModel?
> >
> >
> > On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: TabbedPanel tab names

Posted by Igor Vaynberg <ig...@gmail.com>.
or just ResourceModel

-igor


On Feb 11, 2008 11:59 AM, James Carman <ja...@carmanconsulting.com> wrote:
> Have you tried StringResourceModel?
>
>
> On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: TabbedPanel tab names

Posted by James Carman <ja...@carmanconsulting.com>.
Have you tried StringResourceModel?

On 2/11/08, Michael Mehrle <mi...@ask.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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