Wednesday May 22

Key Concepts

JSF and SEO

JSF and SEO

Attention: open in a new window. PDFPrintE-mail
AddThis Social Bookmark Button

Introduction

Url rewriting is not reserved to PHP solutions. JSF  has now a library able to provide SEO features like :  

  • URL Rewriting — Replace ugly URLs: “/faces/page.jsf” with pretty, SEO-friendly, human URLS: “/optimized/page/”; The client browser never sees your original URLs, even in the source-HTML 
  • Dynamic view IDs — Now with dynamic view ID mapping for URLs (through El method expressions,) you can show different views based on run-time conditions, effectively de-coupling the URL from the JSF  view. 
  • Page-load actions — Call one or more action-methods, at one or more phases, before rendering a view. 
  • Managed parameter parsing — HTTP parameters parsed from URLs are stored in managed beans, simply get a reference to your parameter bean for easy access from other Java classes. 
  • Navigation by ID — Define your page IDs in one place, reference them easily in action-methods and components, using standard JSF  navigation techniques. 
  • Integrated validation — For URL and query-parameters, able to re-use existing JSF  validator objects. 
  • Easy to configure — Requires absolutely minimal configuration; may be enabled using XML or annotations.

Prettyfaces is that library.

PrettyFaces

PrettyFaces is an OpenSource extension for Servlet, Java EE, and JSF , which enables creation of bookmarkable, REST-ful, "pretty" URLs. PrettyFaces solves several problems elegantly, such as: custom URL-rewriting, page-load actions, seamless integration with JSF  navigation and links, dynamic view-id assignment, managed parameter parsing, and configuration-free compatibility with other JSF  frameworks.

Maven dependencies configuration 

Include the following snippet in the <dependencies> section of your project's pom.xml-file:

Maven plugin configuration

<!-- For Servlet/Java EE and <a href="http://java-tutorial.ch/java-server-faces" title="JSF">JSF <img src="http://www.java-tutorial.ch//administrator/components/com_acesef/assets/images/icon-10-external.png"/></a> 2.0 -->
<dependency>
    <groupId>com.ocpsoft</groupId>
    <artifactId>prettyfaces-jsf2</artifactId>
    <version>3.2.0</version>
</dependency>

Tags: java, managed, prettyfaces, urls, dynamic

Add comment


Security code
Refresh

Java Tutorial on Facebook