users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] [jsr344-experts] [971-Multi-Templating] First start

From: Edward Burns <edward.burns_at_oracle.com>
Date: Thu, 24 May 2012 11:01:26 -0700

While the discussion about passthrough attributes (including data-*
attributes) continues, I'd like to get discussion started on 971-Multi
Templating. Here's the commit log for a commit I did on Tuesday. Please
take a look and comment.

SECTION: Modified Files
----------------------------
M integrationWithFacelets.fm (the Facelets chapter)

- New section: Multi-templating

JSF defines a system called "multi-templating" for applying templates to
an entire application. A multi-template is specified as a resource
library that includes the file template.xhtml in its top level. Every
Facelet VDL view in the application will be a template-client of this
template. PENDING: there must be some way for an application to express
which views should have the multi-template applied. Perhaps some kind of
pattern matching system?
[P1-start_facelet_multi_template_inclusion]Implementations must make it
so that, effectively, the multi-template is equivalent to having a
<ui:composition> around every view in the application where the template
attribute of that <ui:composition> refers to the template.xhtml
file.[P1-end_facelet_multi_template_inclusion]

Identifying the Multi-Template

PENDING: do we need to support a list of multi-templates that must be
applied, or is one enough?

The multi-template to apply to the application is identified by means of
the javax.faces.MULTI_TEMPLATE <context-param>. If such a parameter
exists its value is taken to be the name of a resource library
multiTemplate. Otherwise, the value of the symbolic constant
ResourceHandler.DEFAULT_MULTI_TEMPLATE is taken to be the name of a
resource library multiTemplate. If a library named multiTemplate is
accessible to the application, and it contains a resource named
template.xhtml, that resource is assumed to be suitable for use as the
template for an implicit <ui:composition> that is made to be the
template for every Facelet VDL view in the application. Otherwise, the
multi-templating feature is effectively disabled for the application.

M usingFacesInWebapps.fm

- Reference the new context-param

M preface.fm

- reference changes in other files


M jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java

- Add new context-param.

M jsf-api/src/main/java/javax/faces/application/ResourceHandler.java

- Context params related to multi-templating

+ /**
+ * <p class="changed_added_2_2">If a
+ * <code>&lt;context-param&gt;</code> with the param name equal to
+ * the value of {_at_link #MULTI_TEMPLATE_PARAM_NAME}
+ * exists, the runtime must interpret its value as the name of a resource
+ * library that conforms to the naming conventions of a multi-template.</p>
+ * @since 2.2
+ */
+ public static final String MULTI_TEMPLATE_PARAM_NAME =
+ "javax.faces.MULTI_TEMPLATE";

+ /**
+ * <p class="changed_added_2_2">The name of the default multi-template
+ * to look for in the absence of a value for {_at_link #MULTI_TEMPLATE_PARAM_NAME}.</p>
+ * @since 2.2
+ */
+ public static final String DEFAULT_MULTI_TEMPLATE =
+ "javax_faces_template";

M jsf-ri/src/main/java/com/sun/faces/facelets/compiler/SAXCompiler.java

- Implement the requirement to apply a default template to every page if
  a multi-template exists for the current web app.

M jsf-ri/src/main/java/com/sun/faces/facelets/tag/ui/CompositionHandler.java

- As an implementation detail, the value of the "template" attribute
  will be an instance of java.net.URL in the case of the the synthetic
  <ui:composition> inserted when the application has a default template.
  Account for this change.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/