Re: [Wicket-user] Changing localized labels after costructor
On 1/14/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > add(new Label("foo", new ResourceModel("header"))) ? > Yeah, it was really that simple! Thanks -- filippo - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Changing localized labels after costructor
add(new Label("foo", new ResourceModel("header"))) ? -igor On 1/14/07, Filippo Diotalevi <[EMAIL PROTECTED]> wrote: Hi, maybe the question is a bit dumb, but I haven't found a definitive answer. I have a custom panel MyPanel which is added to a MyPage. The component must use internally same labels whose values are localized, and are to be found in MyPage.properties (because MyPanel will be reused in different pages, and with different labels) Now in the constructor of MyPanel I cannot find out which is the page it belongs.. in fact getParent() and getPage() are null (obviously, this isn't a problem with wicket 2 where I have the parent in the constructor) The workaround I've found is to override the getModel method of the labels... something like: //this is the constructor of MyPanel public MyPanel(String id, final BeanModel beanModel) { ..super(id, beanModel); ..add(new Label("header", mybeanModel) { public IModel getModel() { ..String localizedHeader = getLocalizer().getString("header", getPage(), "header"); ..return new Model(localizedHeader); } }); It's a sort of 'late binding' of the label model. Is this solution correct? are there any 'nasty' side effects I'm not aware of? Are there better solutions? Thanks a lot -- Filippo Diotalevi [EMAIL PROTECTED] http://www.diotalevi.com/weblog http://www.jugmilano.it - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] Changing localized labels after costructor
Hi, maybe the question is a bit dumb, but I haven't found a definitive answer. I have a custom panel MyPanel which is added to a MyPage. The component must use internally same labels whose values are localized, and are to be found in MyPage.properties (because MyPanel will be reused in different pages, and with different labels) Now in the constructor of MyPanel I cannot find out which is the page it belongs.. in fact getParent() and getPage() are null (obviously, this isn't a problem with wicket 2 where I have the parent in the constructor) The workaround I've found is to override the getModel method of the labels... something like: //this is the constructor of MyPanel public MyPanel(String id, final BeanModel beanModel) { ..super(id, beanModel); ..add(new Label("header", mybeanModel) { public IModel getModel() { ..String localizedHeader = getLocalizer().getString("header", getPage(), "header"); ..return new Model(localizedHeader); } }); It's a sort of 'late binding' of the label model. Is this solution correct? are there any 'nasty' side effects I'm not aware of? Are there better solutions? Thanks a lot -- Filippo Diotalevi [EMAIL PROTECTED] http://www.diotalevi.com/weblog http://www.jugmilano.it - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user