Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Using nice URL that describe the content of the site will not only improve your ranking but also look more appealling to the users on a SERP (search engine result page). In our case a common URL looks like that:

http://isport.eu/en/premier-league/liverpool-fc/news-19-2008-0.htmlImage Removed

where /en is the language, /premier-league is the currently selected league, /liverpool-fc is the club the page is about, /news are on the page, 19-2008 is the week and 0 is the current page.

...

and then strip the session id in your custom web response.

In your application class add the following:

Wicket 1.5
Code Block

protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse){ 
    return new ServletWebResponse((ServletWebRequest)webRequest, httpServletResponse) {

      @Override
      public String encodeURL(CharSequence url) {
          return isRobot(webRequest) ? url.toString() : super.encodeURL(url);
      }
	  
      @Override
      public String encodeRedirectURL(CharSequence url) {
          return isRobot(webRequest) ? url.toString() : super.encodeRedirectURL(url);
      }

      private boolean isRobot(WebRequest request) {
          final String agent = webRequest.getHeader("User-Agent");
          return /* use 'agent' to decide whether this is a bot */;
      } 
  };
}
Wicket 1.4
Code Block
@Override
protected WebResponse newWebResponse(final HttpServletResponse servletResponse) {
	return new BufferedWebResponse(servletResponse) {
		@Override
		public CharSequence encodeURL(final CharSequence url) {
			final String agent = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest().getHeader("User-Agent");

			return isAgent(agent) ? url : super.encodeURL(url);
		}
	};
}

...

Code Block
@Override
protected Link newPagingNavigationIncrementLink(final String id, final IPageable pageable, final int increment) {
	// return your bookmarkable increment (and decrement) link here
}

@Override
protected Link newPagingNavigationLink(final String id, final IPageable pageable, final int pageNumber) {
	// return your bookmarkable link here
}

@Override
protected PagingNavigation newNavigation(final IPageable pageable, final IPagingLabelProvider labelProvider) {
	return new PagingNavigation("navigation", pageable, labelProvider) {

		private static final long serialVersionUID = 1L;

		@Override
		protected Link newPagingNavigationLink(final String id, final IPageable pageable, final int pageIndex) {
			// return your bookmarkable link here
		}
	};
}

A Describing Page Title For Your Pages, Description and Keywords

As you certainly know, the <title> tag of your page is the one that gets shown on the SERPs, so it should be different for all your pages. If your using a BasePage that holds the layout and use markup inheritance for you SubPages a abstract method. The same idea for description and keywords are applicable.

Code Block

<title wicket:id="title"></title>
<META wicket:id="description" NAME="DESCRIPTION" CONTENT=""/>
<META wicket:id="keywords" NAME="KEYWORDS" CONTENT=""/>
Code Block
public abstract IModel getPageTitle();
public abstract IModel getDescription();
public abstract IModel getKeywords();

is an easy way to force all of your pages to provide a pagetitle, description and keywords. Most commonly the page title depends on your model objects that are going to be displayed on page. E.g. Liverpool FC in the above example. As this object isn't available in the constructor of the superclass, be sure to call getPageTitle() in the onBeforeRenderMethod and also be sure to use addOrReplace instead of only add. e.g.

Code Block
@Override
protected void onBeforeRender() {
	// add the <title> tag
	addOrReplace(new Label("title", getPageTitle()));

    	Label desc = new Label("description","");
    	desc.add( new AttributeAppender("CONTENT", getDescription(), " "));
    	addOrReplace(desc);
    	
    	Label keywords = new Label("keywords","");
    	keywords.add( new AttributeAppender("CONTENT", getKeywords(), " "));
    	addOrReplace(keywords);

	super.onBeforeRender();
}

...