You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kent Larsson <ke...@gmail.com> on 2009/04/16 11:15:44 UTC

Markup inheritance with child pages setting title in the form 'BasePage.title + " - " + ChildPage.title'

Hi,

I use markup inheritance and this example was quite informative
http://wicket.apache.org/examplemarkupinheritance.html .

One thing I find missing is how to set the title from the child pages?

Ideally I would like page titles like:

ApplicationName - Cool part of the application
ApplicationName - Part of the application
ApplicationName - Some other part of the application

It seems like the part 'ApplicationName -' could be set by the base
page and the rest of the string could be appended by the child page.

I have one idea on how to do it:

1. Set an instance variable in the base page called basePageName
2. Use a Label to set the title in the base page
3. Let child pages append their part to the Label

Of course by using some nice methods which are overridden.

Is there a better way to do it?

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


Re: Markup inheritance with child pages setting title in the form 'BasePage.title + " - " + ChildPage.title'

Posted by Kent Larsson <ke...@gmail.com>.
Thank you both! :-) I'll do it that way and use resources.

/ Kent


On Thu, Apr 16, 2009 at 12:50 PM, Cserep Janos <cs...@szeretgom.hu> wrote:
>> CoolPage.PageTitle=ApplicationName - Cool Page Title
>>
>> into your application properties file.
>>
>
>
> From an SEO point of view this approach is more versatile. I usually have
>
> CoolPage.PageTitle
> CoolPage.MetaDescription
> CoolPage.MetaKeywords
>
> all defined in properties files and added from base page. If you put your
> domain object into the page's model (if I have a ContentView page I usually
> put a DetachableContentModel into the page's default model) you can even
> have these string properties reference properties from that object if you
> pass the page's model to the StringResourceModel like this:
>
> public IModel<String> getPageTitleModel() {
>  return new StringResourceModel("ApplicationName", this,
> getDefaultModel());
> }
>

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


Re: Markup inheritance with child pages setting title in the form 'BasePage.title + " - " + ChildPage.title'

Posted by Cserep Janos <cs...@szeretgom.hu>.
> CoolPage.PageTitle=ApplicationName - Cool Page Title
>
> into your application properties file.
>


>From an SEO point of view this approach is more versatile. I usually have

CoolPage.PageTitle
CoolPage.MetaDescription
CoolPage.MetaKeywords

all defined in properties files and added from base page. If you put your
domain object into the page's model (if I have a ContentView page I usually
put a DetachableContentModel into the page's default model) you can even
have these string properties reference properties from that object if you
pass the page's model to the StringResourceModel like this:

public IModel<String> getPageTitleModel() {
  return new StringResourceModel("ApplicationName", this,
getDefaultModel());
}

Re: Markup inheritance with child pages setting title in the form 'BasePage.title + " - " + ChildPage.title'

Posted by Janos Cserep <cs...@metaprime.hu>.
> 1. Set an instance variable in the base page called basePageName


You don't need a variable - all you need is a getter:

public IModel<String> getPageTitleModel() {
  return new Model("ApplicationName");
}


> 2. Use a Label to set the title in the base page


Exactly, like this:

add(new Label("pageTitle", getPageTitleModel());


>
> 3. Let child pages append their part to the Label
>

public IModel<String> getPageTitleModel() {
  return new Model("ApplicationName - Cool Page");
}


Another approach (this way you handle localization and don't have to
override anything in your pages):

public IModel<String> getPageTitleModel() {
  return new StringResourceModel(this.getClass().getSimpleName() +
".PageTitle", this, null);
}

and put

CoolPage.PageTitle=ApplicationName - Cool Page Title

into your application properties file.