
Changing to JSF2 brought some basic changes to the way layout.xhtml files need to be written. The following steps are at least nescessary to update a layout to JSF2:
- the <head /> element must be changed into a <h:head />
- The new namespace URL for xmlns:c is http://java.sun.com/jsp/jstl/core (jsp/ added)
- Elements that get reloaded by AJAX have to be real JSF components and not just facelets markup. That means that at least the divs with the ids “content” and “page” have to be changed into <os:div id=”content” /> and <os:div id=”page” />. Don’t forget to also change the class attribute into a styeClass attribute if there is one.
- All <ui:fragment /> tags should be removed since they’re no longer needed for AJAX updates.
- <div id=”contextPath”> … </div> also has a class=”contextPath” now. id=”contextPath” means “this is the OpenSAGA domain context path” component, the class “contextPath” only sets the visual presentation of it. This distinction can be useful when delivering cached content.
- the main form has a fixed id now. <os:mainForm id=”osForm” enctype=”multipart/form-data”>
In general, JSF2 is much more picky about IDs. Which means e.g. that you can’t define two alternate versions of the same component with the same id, selected by <c:if />s. For this reason, the top-menu variant of the OpenSAGA theme is currently broken and will be fixed soon in trunk.
Der Umstieg auf JSF2 hat einige grundlegende Änderungen in den layout.xhtml files mit sich gebracht. Die folgenden Änderungen sind mindestens notwendig, um ein Layout auf JSF2 zu aktualisieren:
- Das <head /> element muss durch <h:head />ersetzt werden
- Die neue namespace URL für xmlns:c ist http://java.sun.com/jsp/jstl/core (jsp/ added)
- Elemente, die per AJAX neu geladen werden müssen richtige JSF-Komponenten sein und nicht nur faceltes markup.Das heisst das zumindest die divs mit den ids “content” und “page” in <os:div id=”content” /> und <os:div id=”page” /> geändert werden müssen. class Attribute müssen in styleClass Attribute geändert werden.
- Alle <ui:fragment /> tags sollten entfernt werden, da sie nicht mehr für AJAX-Updates benötigt werden.
- <div id=”contextPath”> … </div> hat auch ein class=”contextPath” now. id=”contextPath” bedeutet “Dies ist der OpenSAGA domain context path”, die Klasse “contextPath” setzt nur das Aussehen des Domain-Context-Pfad. Diese Unterscheidung kann nützlich sein, wenn man gecachten Content ausliefert.
- Die main form hat jetzt eine feste Id. <os:mainForm id=”osForm” enctype=”multipart/form-data”>
Generell ist JSF2 viel empfindlicher, was die IDs angeht. Das bedeutet zum Beispiel, dass man nicht mehr zwei alternative Versionen der selben Komponente mit der selben Id definieren kann um diese dann mit <c:if /> auszuwählen. Aus diesem Grund ist die Top-Menu Variante des OpenSAGA-Layouts zur Zeit auch kaputt (wird in den nächsten Tagen repariert).