Jakarta EE Components
Jakarta Faces Configuration
Sensible Jakarta Faces defaults for development and production, set up as soon as the library is on your classpath.
Some of these features work as soon as Flow Logix is in your application. The others are enabled with one setting.
| Feature | How to enable |
|---|---|
Automatic |
|
|
|
Automatic |
|
|
|
|
|
Automatic |
Development mode by default
Jakarta Faces runs in production mode by default, and most applications switch to development mode by editing web.xml,
which makes it hard to switch between development and production per environment.
Flow Logix sets development mode up automatically, through web-fragment.xml, and lets you switch to production mode with JNDI.
|
Note
|
Special entries in web.xml, glassfish-web.xml or any other container-specific configuration are no longer required, and can be removed.
|
To switch to production mode with Payara or GlassFish, on Jakarta EE 9 or later:
asadmin create-custom-resource --resType=java.lang.String \
--factoryClass=org.glassfish.resources.custom.factory.PrimitivesAndStringFactory faces/ProjectStage
asadmin set resources.custom-resource.faces/ProjectStage.property.value=Production
With Jakarta EE 8, Java EE 8 or earlier, replace faces/ with jsf/.
Minified assets in production
Most applications want to serve minified JavaScript and CSS outside development mode.
MinimizedHandler does this by inserting min into the names of the assets,
for example resource.js becomes resource.min.js, and resource.css becomes resource.min.css.
It works with build tools that generate the minified files for you, such as the
Minify Maven Plugin.
<application>
<resource-handler>com.flowlogix.ui.MinimizedHandler</resource-handler>
</application>
Jakarta Faces resources then resolve to their minified versions:
myjavascript.min.js<h:outputScript name="myjavascript.js"/>
other.min.css@import url("#{resource['css/other.css']}");
Change what is minified
By default, only resources with the css and js extensions are resolved, and min is inserted before the original extension.
Both are configurable with web.xml context parameters.
mycss.css to mycss.minimized.css instead of mycss.min.css<context-param>
<param-name>com.flowlogix.MINIMIZED_PREFIX</param-name>
<param-value>minimized</param-value>
</context-param>
css, js)<context-param>
<param-name>com.flowlogix.MINIMIZED_FILE_TYPES</param-name>
<param-value>css, js, tsx, sass, scss, less</param-value>
</context-param>
Facelets refresh in development
Jakarta Faces caches Facelets templates for 2 seconds in development mode, and indefinitely in production mode.
In development mode, Flow Logix sets jakarta.faces.FACELETS_REFRESH_PERIOD to zero, which disables the cache completely.
This is critical for live reload.
To keep the cache in development mode, set this parameter, which has no effect in production mode:
<!-- Optional. The default is true in development mode, false otherwise -->
<context-param>
<param-name>com.flowlogix.faces.DISABLE_CACHE</param-name>
<param-value>false</param-value>
</context-param>
Larger Facelets buffer in development
Jakarta Faces uses a 1 KB Facelets buffer by default, which is often too small in development. If an error occurs in a Facelets template, the buffer fills up before the error page can be rendered, and the browser shows a blank or incomplete page instead of the error.
Flow Logix can raise jakarta.faces.FACELETS_BUFFER_SIZE for you, in development mode only.
To enable it, set this parameter. The value is in kilobytes.
<context-param>
<param-name>com.flowlogix.set-facelet-buffer-size</param-name>
<param-value>64</param-value>
</context-param>
OmniFaces UnmappedResourceHandler
OmniFaces' UnmappedResourceHandler
ordinarily needs both a servlet-mapping in web.xml and an entry in faces-config.xml.
Flow Logix configures the servlet container to include all unmapped resources instead,
so you don’t need a Faces Servlet mapping in web.xml at all. To enable it:
<context-param>
<param-name>com.flowlogix.add-unmapped-resources</param-name>
<param-value>true</param-value>
</context-param>
PrimeFaces font MIME types
PrimeFaces includes fonts in your application, but most servlet containers don’t know their file extensions.
Flow Logix adds those MIME types automatically, so you don’t need mime-mapping entries in web.xml,
and warnings like this one no longer appear in the logs:
WARNING: JSF1091: No mime type could be found for file font1.woff2