Thank you all for your help. it worked. Igor,
do you mean that getPageTitle() virtual method of subclass will be called from constructor of the base class? but in the implementation below it doesn't reference any members of subclass, it simply creates new ResourceModel object. am i missing something? and in the fix you suggested pagetitlemodel.getObject() will be called when subclass page will be rendered, that is after subclass is constructed. is this correct? Vadim >From: "Igor Vaynberg" <[EMAIL PROTECTED]> >Reply-To: [email protected] >To: [email protected] >Subject: Re: [Wicket-user] question on localization >Date: Tue, 24 Apr 2007 11:00:05 -0700 > >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 >> > [email protected] >> > 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 >>[email protected] >>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 >[email protected] >https://lists.sourceforge.net/lists/listinfo/wicket-user _________________________________________________________________ Exercise your brain! Try Flexicon. http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglineapril07 ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
