Facelets: Difference between revisions

From Wiki RB4
Line 12: Line 12:
  </faces-config>
  </faces-config>


JavaServer Faces defaults to JSP files for defining views (*.jsp). You will want to change this to some other type in your [[JavaJEE#|web.xml]].
JavaServer Faces defaults to JSP files for defining views (*.jsp). You will want to change this to some other type in your [[JEE#WAR-Files|web.xml]].
J
J
  <context-param>
  <context-param>

Revision as of 21:38, 1 September 2008

Introduction

Facelets ist eine alternative View-Handler Technologie für das JavaServer Faces Framework, das heißt es ersetzt JavaServer Pages für die Definition der Views. Facelets setzt als Eingabe gültige XML-Dokumente voraus. Deshalb werden die Seiten im XHTML-Format erstellt. Ein wichtiges Merkmal von Facelets ist das sogenannte component-aliasing. Damit ist es möglich, statt der Tags für die UI-Komponenten normale HTML-Tags, wie zum Beispiel <input> zu nutzen. Die Verbindung zu der UI-Komponente wird über das alias-Attribut jsfc im Tag hergestellt. Die entsprechende Komponente wird beim Kompilieren der Seite durch Facelets eingefügt. Der Vorteil des component-aliasing ist, dass Webdesigner die Seite mit herkömmlichen HTML-Editoren bearbeiten können, da die normalen HTML-Tags benutzt werden. Die zusätzlichen Attribute werden ignoriert.

Implementation

Facelets is implemented as a JSF ViewHandler, which can be easily configured in your application. Simply make sure the Facelets JAR (jsf-facelets.jar) is in your project's classpath and add a single modification to your faces-config.xml:

<faces-config>
  <application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
  </application>
</faces-config>

JavaServer Faces defaults to JSP files for defining views (*.jsp). You will want to change this to some other type in your web.xml. J

<context-param>
  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  <param-value>.xhtml</param-value>
</context-param>