On 3/4/08, Sebastiaan van Erk <[EMAIL PROTECTED]> wrote:
> James Carman wrote:
>
> > The problem with this approach is that you're not able to localize the
> > title if you hard-code it. What I've done is actually specify a key
> > for my messages file and I use that. So, every page has to define its
> > page.title key in its PageClass.properties file.
>
>
> That's what I do it too. :-) In applications that are localized I change the
>
>
> add(new Label("title", title))
>
>
> with
>
> add(new Label("title", new StringResourceModel(titleKey, this, new
> CompoundPropertyModel(this)));
Very nice! I like the fact that you can do substitutions with this.
I had that problem on the back burner in my brain until I needed to
solve it. But, you took care of it for me. Thanks!
>
> This has the added benefit that you can do nice property substitutions,
> that is, if the titleKey resolves to "Profile for ${session.userName}"
> then you'll get a nice title "Profile for Sebastiaan" dynamically. :-) I
> don't use a static key though (like page.title) because my keys come
> from the database and I have little web page with a tree view where you
> can edit the key values. :-)
>
> Regards,
>
> Sebastiaan
>
>
> >> Kaspar Fischer wrote:
> >> > I am using markup inheritance (<wicket:child> and <wicket:extend>) and
> >> > need to set the
> >> > page title from my subpage. I currently add a label in the base class
> >> > (BasePage.java)
> >> > and make it use an abstract method getTitle(), which is overridden in
> >> > the subclass
> >> > (SubPage.java). Has anybody found a better way?
> >> >
> >> > Here's my solution:
> >> >
> >> > <!-- BasePage.html -->
> >> > <html>
> >> > <head>
> >> > <title wicket:id="title">[Page title]</title>
> >> > </head>
> >> > <body>
> >> > <wicket:child/>
> >> > </body>
> >> > </html>
> >> >
> >> > <!-- SubPage.html -->
> >> > <wicket:extend>
> >> > <!-- anything ... -->
> >> > </wicket:extend>
> >> >
> >> >
> >> > public abstract class BasePage extends WebPage
> >> > {
> >> > // ...
> >> > public BasePage(final PageParameters parameters)
> >> > {
> >> > add(new Label("title", new PropertyModel(this, "title")));
> >> > }
> >> > public abstract String getTitle();
> >> > }
> >> >
> >> > public class SubPage extends BasePage
> >> > {
> >> > // ...
> >> > public String getTitle()
> >> > {
> >> > return "whatever title";
> >> > }
> >> > }
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]