Java Magazine, July/August 2016
ORACLE COM JAVAMAGAZINE JULY AUGUST 2016 22 enterprise java Lines 4 and 5 are wrapped due to space constraints and should be entered as a single line as are lines 10 and 11 Ed A rather important aspect of full class bean validation in combination with JSF is that the bean seen by the validator is a copy of the backing bean and not the actual backing bean The reason for this is that the JSF validation semantics demand that the model the backing bean is not updated when any validation or conversion failure happens However full class bean validation can happen only after the bean has been fully updated To break this mismatch the runtime first makes a copy of the backing bean updates this copy and validates it Only if all validation constraints pass is the actual backing bean updated Extensionless URLs JSF is implemented internally via a servlet the so called FacesServlet which listens to requests that have a specific pattern By default this pattern includes faces jsf faces and as of JSF 23 xhtml Users can set their own pattern in web xml using the same servlet syntax thats used to map any servlet to a URL pattern As can be seen from the information above both path mapping and extension mapping are supported An example of path mapping would be http example com faces page xhtml while an example of extension mapping would be something like http example com page jsf In modern web applications its often desirable to have clean URLs that is URLs that specifically dont have an extension and generally dont have any kind of clutter in them Unfortunately JSF does not support such URLs out of the box Curiously even when you are using path mapping an extension is still required as shown above Clean URLs in JSF can be obtained by using third party libraries such as PrettyFaces or OmniFaces but this kind of functionality is now deemed to be sufficiently well understood and mature that it qualifies for inclusion in JSF itself The goal for extensionless URLs in JSF 23 is threefold First path mapping should work without an extension For example a URL such as http example com faces page should work out of the box Second exact mapping should be oficially supported For example a URL such as http example com page should work when the following mapping is present in web xml servlet servlet name Faces Servlet servlet name servlet class javax faces webapp FacesServlet servlet class servlet servlet mapping servlet name Faces Servlet servlet name url pattern page url pattern servlet mapping Third the most ambitious part of the goal is that a URL such as http example com page should work without requiring the user to map page or any page explicitly by using exact mapping but rather it should work by setting only a single configuration option At press time its not yet clear how the third goal should be implemented but a possible approach would be adding a new listViewResources method to the ResourceHandler and then taking advantage of the Servlet 30 specs programmatic mapping during application startup to automatically add exact mappings for all view resources for example Facelets that are handled by a given ResourceHandler Programmatic and Annotation Based Configuration High level declarative configuration in JSF is done using either context parameters in web xml or the dedicated faces config xml files Additionally there are some
You must have JavaScript enabled to view digital editions.