You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tito <nj...@gmail.com> on 2011/04/12 14:24:57 UTC

Custom head title on subpage

Hi I don't know the best way to make title of page depends on subpage.

I have a BasePage with a header, footer, etc. My concrete pages extends from
BasePage. Then I want to have different title on each page.

What do you recomend?

Thanks

Re: Custom head title on subpage

Posted by Martin Grigorov <mg...@apache.org>.
Each sub page will do:

protected IModel<String>provideTitleModel() {
  return new ResourceModel("the.page.title.property.for.that,page")
}

On Tue, Apr 12, 2011 at 3:10 PM, Tito <nj...@gmail.com> wrote:

> I like this Idea but, how do you solve language issue?
> I mean, how can i do in concrete class to provide a different title
> depending on language.
>
> Now i'm working with a properties file with <wicket:message
> key="page.title"
> />
> Defining a properties file for every page it seems to work but it is not so
> confortable.
>
> Thanks for the answer!
>
>
> 2011/4/12 Michael O'Cleirigh <mi...@rivulet.ca>
>
> > You can normally use wicket in the <head> or <wicket:head> sections.
> >
> > I use this approach to set my page favicon (which is the <link> tag).
> >
> > It should also work for the <title> tag.
> >
> > e.g. put a wicket:id into the title tag in the head section of the base
> > page:
> >
> > <html>
> > <head>
> > <title wicket:id="title"></title>
> > </head>
> > <body>
> > <wicket:child/>
> > </body>
> > </html>
> >
> > And then in your BasePage:
> >
> > onInitialize() {
> >
> >    add (new Label("title", provideTitleModel());
> >
> > }
> >
> > /**
> >  * Let the concrete child classes provide the content for the title.
> >  */
> > protected abstract IModel<String>provideTitleModel();
> >
> > Regards,
> >
> > Mike
> >
> >  Hi I don't know the best way to make title of page depends on subpage.
> >>
> >> I have a BasePage with a header, footer, etc. My concrete pages extends
> >> from
> >> BasePage. Then I want to have different title on each page.
> >>
> >> What do you recomend?
> >>
> >> Thanks
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Custom head title on subpage

Posted by Tito <nj...@gmail.com>.
Thank you Igor, I'm reading this now.

Tito

2011/4/12 Igor Vaynberg <ig...@gmail.com>

> My book had a recipe for a flexible solution for managing the page
> title, and as luck would have it its in the chapter that was made
> available for free:
> http://www.packtpub.com/sites/default/files/downloads/1605_Chapter12.pdf
>
> -igor
>
>
> On Tue, Apr 12, 2011 at 7:40 AM, Tito <nj...@gmail.com> wrote:
> > Thank you everybody.
> >
> > I think it could be solve with .properties hierarchy in that case. I
> don't
> > have to use java code and just redifining page.title property for every
> page
> > it should work.
> >
> > I thought perhaps wicket had something like a page template that i could
> > override in html concrete page.
> >
> > Tito
> >
> > 2011/4/12 sonxurxo <so...@gmail.com>
> >
> >> What about using Page#getString(String key) method? If you have your
> >> .properties files with language suffixes (e.g. MyPage_en.properties,
> >> MyPage_es.properties, MyPage_fr.properties) Wicket will automatically
> >> retrieve the String resource from the properties file of the session
> >> language.
> >>
> >> -----
> >> http://blog.sonxurxo.com
> >> --
> >> View this message in context:
> >>
> http://apache-wicket.1842946.n4.nabble.com/Custom-head-title-on-subpage-tp3444481p3444664.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>

Re: Custom head title on subpage

Posted by Igor Vaynberg <ig...@gmail.com>.
My book had a recipe for a flexible solution for managing the page
title, and as luck would have it its in the chapter that was made
available for free:
http://www.packtpub.com/sites/default/files/downloads/1605_Chapter12.pdf

-igor


On Tue, Apr 12, 2011 at 7:40 AM, Tito <nj...@gmail.com> wrote:
> Thank you everybody.
>
> I think it could be solve with .properties hierarchy in that case. I don't
> have to use java code and just redifining page.title property for every page
> it should work.
>
> I thought perhaps wicket had something like a page template that i could
> override in html concrete page.
>
> Tito
>
> 2011/4/12 sonxurxo <so...@gmail.com>
>
>> What about using Page#getString(String key) method? If you have your
>> .properties files with language suffixes (e.g. MyPage_en.properties,
>> MyPage_es.properties, MyPage_fr.properties) Wicket will automatically
>> retrieve the String resource from the properties file of the session
>> language.
>>
>> -----
>> http://blog.sonxurxo.com
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Custom-head-title-on-subpage-tp3444481p3444664.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> 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: Custom head title on subpage

Posted by Tito <nj...@gmail.com>.
Thank you everybody.

I think it could be solve with .properties hierarchy in that case. I don't
have to use java code and just redifining page.title property for every page
it should work.

I thought perhaps wicket had something like a page template that i could
override in html concrete page.

Tito

2011/4/12 sonxurxo <so...@gmail.com>

> What about using Page#getString(String key) method? If you have your
> .properties files with language suffixes (e.g. MyPage_en.properties,
> MyPage_es.properties, MyPage_fr.properties) Wicket will automatically
> retrieve the String resource from the properties file of the session
> language.
>
> -----
> http://blog.sonxurxo.com
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Custom-head-title-on-subpage-tp3444481p3444664.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Custom head title on subpage

Posted by sonxurxo <so...@gmail.com>.
What about using Page#getString(String key) method? If you have your
.properties files with language suffixes (e.g. MyPage_en.properties,
MyPage_es.properties, MyPage_fr.properties) Wicket will automatically
retrieve the String resource from the properties file of the session
language.

-----
http://blog.sonxurxo.com
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-head-title-on-subpage-tp3444481p3444664.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Custom head title on subpage

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> I mean, how can i do in concrete class to provide a different title
> depending on language.

Your title model class could check Session.get().getLocale() to decide what text to return from getObject().

- Tor Iver

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom head title on subpage

Posted by Tito <nj...@gmail.com>.
I like this Idea but, how do you solve language issue?
I mean, how can i do in concrete class to provide a different title
depending on language.

Now i'm working with a properties file with <wicket:message key="page.title"
/>
Defining a properties file for every page it seems to work but it is not so
confortable.

Thanks for the answer!


2011/4/12 Michael O'Cleirigh <mi...@rivulet.ca>

> You can normally use wicket in the <head> or <wicket:head> sections.
>
> I use this approach to set my page favicon (which is the <link> tag).
>
> It should also work for the <title> tag.
>
> e.g. put a wicket:id into the title tag in the head section of the base
> page:
>
> <html>
> <head>
> <title wicket:id="title"></title>
> </head>
> <body>
> <wicket:child/>
> </body>
> </html>
>
> And then in your BasePage:
>
> onInitialize() {
>
>    add (new Label("title", provideTitleModel());
>
> }
>
> /**
>  * Let the concrete child classes provide the content for the title.
>  */
> protected abstract IModel<String>provideTitleModel();
>
> Regards,
>
> Mike
>
>  Hi I don't know the best way to make title of page depends on subpage.
>>
>> I have a BasePage with a header, footer, etc. My concrete pages extends
>> from
>> BasePage. Then I want to have different title on each page.
>>
>> What do you recomend?
>>
>> Thanks
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Custom head title on subpage

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
You can normally use wicket in the <head> or <wicket:head> sections.

I use this approach to set my page favicon (which is the <link> tag).

It should also work for the <title> tag.

e.g. put a wicket:id into the title tag in the head section of the base 
page:

<html>
<head>
<title wicket:id="title"></title>
</head>
<body>
<wicket:child/>
</body>
</html>

And then in your BasePage:

onInitialize() {

     add (new Label("title", provideTitleModel());

}

/**
  * Let the concrete child classes provide the content for the title.
  */
protected abstract IModel<String>provideTitleModel();

Regards,

Mike
> Hi I don't know the best way to make title of page depends on subpage.
>
> I have a BasePage with a header, footer, etc. My concrete pages extends from
> BasePage. Then I want to have different title on each page.
>
> What do you recomend?
>
> Thanks
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org