Ah, yes, this is much better. It bothered me enough to put a warning in
the Javadoc, but that's a poor substitute for something that just works.
I'll be fixing our code in the morning. Thanks Igor.

jk

On Tue, Apr 24, 2007 at 11:00:05AM -0700, Igor Vaynberg wrote:
> this is bad. getpagetitle() might get called from a partially constructed
> object
> 
> it should be
> 
>    public BasePage() {
>        add(new Label("pageHeaderTitle", new pagetitlemodel()));
>    }
> 
>    private class pagetitlemodel extends abstractreadonlymodel {
>        object getobject() { return getpagetitle().getobject(); }
>        void detach() { getpagetitle().detach(); }
>     }
> 
> -igor
> 
> On 4/24/07, John Krasnay <[EMAIL PROTECTED]> wrote:
> >
> >You might want to make it so you can dynamically generate a page title
> >where you need to, instead of always requiring a static page title. The
> >trick is to return an IModel from the getPageTitle method in your base
> >page. Here's how I've done it:
> >
> ><title wicket:id="pageHeaderTitle">Foo</title>
> >
> >public class BasePage extends WebPage {
> >
> >    public BasePage() {
> >        add(new Label("pageHeaderTitle", getPageTitle()));
> >    }
> >
> >    public IModel getPageTitle() {
> >        return new ResourceModel("page.title");
> >    }
> >}
> >
> >jk
> >
> >On Tue, Apr 24, 2007 at 10:33:54AM +0900, David Leangen wrote:
> >> > i tried to use Label() with PropertyModel("pageTitle") but didn't work
> >for
> >> > me.  it rendered "Home" string all the time, no matter what the locale
> >was.
> >> > any ideas how to do this?
> >>
> >> You can do something like this:
> >>
> >> new Label( componentId, new StringResourceModel( "pageTitle", this, new
> >> Model() ) );
> >>
> >> In your properties file:
> >> pageTitle=Home
> >>
> >> In your html:
> >> <span wicket:id="componentId">Dummy text</span>
> >>
> >>
> >> Look for StringResourceModel in ProWicket or in the API docs.
> >>
> >>
> >> HTH
> >> Dave
> >>
> >>
> >>
> >>
> >>
> >-------------------------------------------------------------------------
> >> This SF.net email is sponsored by DB2 Express
> >> Download DB2 Express C - the FREE version of DB2 express and take
> >> control of your XML. No limits. Just data. Click to get it now.
> >> http://sourceforge.net/powerbar/db2/
> >> _______________________________________________
> >> Wicket-user mailing list
> >> Wicket-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >-------------------------------------------------------------------------
> >This SF.net email is sponsored by DB2 Express
> >Download DB2 Express C - the FREE version of DB2 express and take
> >control of your XML. No limits. Just data. Click to get it now.
> >http://sourceforge.net/powerbar/db2/
> >_______________________________________________
> >Wicket-user mailing list
> >Wicket-user@lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/wicket-user
> >

> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to