You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bergmann Manfred <mb...@software-by-mabe.com> on 2009/08/27 11:47:50 UTC
Subclass of base page class not rendered
Hi there.
I've run into an issue and don't know how to solve it.
My experience with Wicket is still low.
I have a BasePage, subclass of WebPage. This page has some links,
including links to change the language.
This BasePage is not a page that is "rendered" directly. Only though
subclasses.
However the link events are handled on the BasePage. In the link
handler the locale is changed in the session and the last rendered
page should get re-rendered.
It looks like that BasePage subclass is re-rendered because
<wicket:message/> messages are localized. But some others components
are not.
In fact the constructor of the subclass is not called again and that's
the reason for some components are still in the old language.
How can I force to re-instantiate this subclass while not knowing
which subclass it is in the link click-handler?
Regards,
Manfred
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Subclass of base page class not rendered
Posted by Jeremy Thomerson <je...@wickettraining.com>.
You're going about this the wrong way. You shouldn't force a
re-instantiation. The real problem here is that your components are
not shown as localized because apparently you are pushing the strings
into your components in the constructors. Instead, you should use a
model that always pulls the strings based on current state.
i.e., instead of:
MyConstructor {
add(new Label("foo", getString("some.key"));
}
You should be doing:
MyConstructor {
add(new Label("foo", new ResourceModel("some.key"));
}
Incorrect use of models is the most common Wicket learning mistake. I
suspect that's what this is.
--
Jeremy Thomerson
http://www.wickettraining.com
On Thu, Aug 27, 2009 at 4:47 AM, Bergmann
Manfred<mb...@software-by-mabe.com> wrote:
> Hi there.
>
> I've run into an issue and don't know how to solve it.
> My experience with Wicket is still low.
>
> I have a BasePage, subclass of WebPage. This page has some links, including
> links to change the language.
> This BasePage is not a page that is "rendered" directly. Only though
> subclasses.
> However the link events are handled on the BasePage. In the link handler the
> locale is changed in the session and the last rendered page should get
> re-rendered.
> It looks like that BasePage subclass is re-rendered because
> <wicket:message/> messages are localized. But some others components are
> not.
> In fact the constructor of the subclass is not called again and that's the
> reason for some components are still in the old language.
> How can I force to re-instantiate this subclass while not knowing which
> subclass it is in the link click-handler?
>
>
> Regards,
> Manfred
>
> ---------------------------------------------------------------------
> 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: Subclass of base page class not rendered
Posted by Pedro Santos <pe...@gmail.com>.
To force re-instantiate of an unknow subclass you can use reflection like:
setResponsePage(getPage().getClass().getConstructors()[0].newInstance());
but a simple setResponsePage(getPage()) should work to update resources used
by wicket:message for example....
On Thu, Aug 27, 2009 at 6:47 AM, Bergmann Manfred
<mb...@software-by-mabe.com>wrote:
> Hi there.
>
> I've run into an issue and don't know how to solve it.
> My experience with Wicket is still low.
>
> I have a BasePage, subclass of WebPage. This page has some links, including
> links to change the language.
> This BasePage is not a page that is "rendered" directly. Only though
> subclasses.
> However the link events are handled on the BasePage. In the link handler
> the locale is changed in the session and the last rendered page should get
> re-rendered.
> It looks like that BasePage subclass is re-rendered because
> <wicket:message/> messages are localized. But some others components are
> not.
> In fact the constructor of the subclass is not called again and that's the
> reason for some components are still in the old language.
> How can I force to re-instantiate this subclass while not knowing which
> subclass it is in the link click-handler?
>
>
> Regards,
> Manfred
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>