Skip to content

Commit

Permalink
Deprecate and remove Facelets requirement
Browse files Browse the repository at this point in the history
closes: #65
  • Loading branch information
erdlet committed Oct 23, 2022
1 parent e9ffc57 commit 2112dca
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 48 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/jakarta/mvc/Models.java
Expand Up @@ -24,7 +24,7 @@
* to process a view. Instances implementing this interface must be injectable using
* {@link jakarta.inject.Inject} and are {@link jakarta.enterprise.context.RequestScoped}.
*
* <p>Note that certain view engines, such as engines for Jakarta Server Pages and Facelets, support
* <p>Note that certain view engines, such as the engine for Jakarta Server Pages, support
* model binding via {@link jakarta.inject.Named} in which case the use of Models is
* optional.
*
Expand Down
5 changes: 2 additions & 3 deletions api/src/main/java/jakarta/mvc/engine/ViewEngine.java
Expand Up @@ -33,10 +33,9 @@
* <li>Call method {@link #processView(ViewEngineContext)} to process view.</li>
* <li>Fire a {@link jakarta.mvc.event.AfterProcessViewEvent} event.</li>
* </ol>
* <p>The default view engines for Jakarta Server Pages and Facelets use file extensions to determine
* <p>The default view engine for Jakarta Server Pages uses file extensions to determine
* support. Namely, the default Jakarta Server Pages view engine supports views with extensions <code>jsp</code>
* and <code>jspx</code>, and the one for Facelets supports views with extension
* <code>xhtml</code>.</p>
* and <code>jspx</code>.</p>
*
* @author Santiago Pericas-Geertsen
* @author Ivar Grimstad
Expand Down
19 changes: 2 additions & 17 deletions spec/src/main/asciidoc/chapters/controllers.asciidoc
Expand Up @@ -193,7 +193,7 @@ Models
Jakarta MVC controllers are responsible for combining data models and views (templates) to produce web application pages.
This specification supports two kinds of models: the first is based on CDI `@Named` beans,
and the second on the `Models` interface which defines a map between names and objects.
[tck-testable tck-id-builtin-both-models]#Jakarta MVC provides view engines for Jakarta Server Pages and Facelets out of the box, which support both types#.
[tck-testable tck-id-builtin-both-models]#Jakarta MVC provides a view engine for Jakarta Server Pages out of the box, which support both types#.
For all other view engines supporting the `Models` interface is mandatory,
support for CDI `@Named` beans is OPTIONAL but highly RECOMMENDED.

Expand Down Expand Up @@ -289,21 +289,6 @@ Here is the Jakarta Server Pages page for the hello-world example:
[tck-testable tck-id-jsp-el]#In Jakarta Server Pages, model properties are accessible via EL# [<<el30,6>>]. In the example above, the property `message` is read from the `greeting` model
whose name was either specified in a `@Named` annotation or used as a key in the `Models` map, depending on which controller from the <<models>> section triggered this view's processing.

Here is the corresponding example using Facelets instead of Jakarta Server Pages:

[source,html,numbered]
----
<!DOCTYPE html>
<html lang="en" xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Hello</title>
</h:head>
<h:body>
<h:outputText value="#{greeting.message}" />
</h:body>
</html>
----

[[mvc_uri]]
Building URIs in a View
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -383,4 +368,4 @@ Given such a controller class, the view can generate a matching URI by referenci
${mvc.uri('book-list')}
----

Please note that this feature will work with Jakarta Server Pages, Facelets and all view engines which support invoking methods on CDI model objects.
Please note that this feature will work with Jakarta Server Pages and all view engines which support invoking methods on CDI model objects.
28 changes: 2 additions & 26 deletions spec/src/main/asciidoc/chapters/engines.asciidoc
Expand Up @@ -12,7 +12,7 @@ Introduction
A _view engine_ is responsible for processing views. In this context, processing entails (i) locating and loading a view (ii) preparing any
required models and (iii) rendering the view and writing the result back to the client.

[tck-testable tck-id-jsp-facelets]#Implementations MUST provide built-in support for Jakarta Server Pages and Facelets view engines#.
[tck-testable tck-id-jsp]#Implementations MUST provide built-in support for Jakarta Server Pages#.
Additional engines may be supported via an extension mechanism based on Jakarta Contexts and Dependency Injection.
[tck-testable tck-id-cdi-discovery]#Namely, any Jakarta Contexts and Dependency Injection bean that implements the `jakarta.mvc.engine.ViewEngine` interface MUST be considered as a possible target for processing by calling its `supports` method, discarding the engine if this method returns `false`#.

Expand Down Expand Up @@ -41,34 +41,10 @@ The `processView` method has all the information necessary for processing in the

Prior to the view render phase, all entries available in `Models` MUST be bound in such a way that they become available to the view being processed.
The exact mechanism for this depends on the actual view engine implementation.
[tck-testable tck-id-models-binding]#In the case of the built-in view engines for JSPs and Facelets, entries in `Models` must be bound by calling `HttpServletRequest.setAttribute(String, Object)`#.
[tck-testable tck-id-models-binding]#In the case of the built-in view engines for JSPs, entries in `Models` must be bound by calling `HttpServletRequest.setAttribute(String, Object)`#.
Calling this method ensures access to the named models from EL expressions.

A view returned by a controller method represents a path within an application archive.
[tck-testable tck-id-path-relative]#If the path is relative, does not start with `/`, implementations MUST resolve view paths relative to the view folder, which defaults to `/WEB-INF/views/`#.
[tck-testable tck-id-path-absolute]#If the path is absolute, no further processing is required#.
It is recommended to use relative paths and a location under `WEB-INF` to prevent direct access to views as static resources.

[[faces_servlet]]
FacesServlet
~~~~~~~~~~~~

Because Facelets support is not enabled by default, Jakarta MVC applications that use Facelets are required to package a `web.xml` deployment descriptor with the following entry mapping the extension `*.xhtml` as shown next:

[source,xml,numbered]
----
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
----

Alternatively to a `web.xml` deployment descriptor an empty `faces-config.xml` file can be placed in the `WEB-INF` folder to enable Facelets support.

It is worth noting that if you opt to use Facelets as a view technology for your Jakarta MVC application, regular Jakarta Server Faces post-backs will not be processed by the Jakarta MVC runtime.
The usage of `<h:form />` and depending form components like `<h:inputText />` is not recommended as they would be the entry point to a real Jakarta Server Faces application.
2 changes: 1 addition & 1 deletion spec/src/main/asciidoc/chapters/intro.asciidoc
Expand Up @@ -24,7 +24,7 @@ The following are goals of the API:
Goal 1:: Leverage existing Jakarta EE technologies like Jakarta Contexs and Dependency Injecttion [<<cdi20,2>>] and Jakarta Bean Validation [<<bv20,3>>].
Goal 2:: Define a solid core to build MVC applications without necessarily supporting all the features in its first version.
Goal 3:: Build on top of Jakarta RESTful Web Services for the purpose of re-using its matching and binding layers.
Goal 4:: Provide built-in support for Jakarta Server Pages and Facelets view languages.
Goal 4:: Provide built-in support for Jakarta Server Pages view languages.

[[non_goals]]
Non-Goals
Expand Down
11 changes: 11 additions & 0 deletions spec/src/main/asciidoc/chapters/revision.asciidoc
Expand Up @@ -2,6 +2,17 @@
[[revision_history]]
Revision History
----------------
3.0
[[version_three_zero]]
~~~

Deprecate requirement for Facelets support

2.1
[[version_two_one]]
~~~

Specified `FormMethodOverwrite` for extended HTTP method support

2.0
[[version_two_zero]]
Expand Down

0 comments on commit 2112dca

Please sign in to comment.