15

In a JSF application, the parameter javax.faces.FACELETS_REFRESH_PERIOD can be used to enable/disable automatic reloading of XHTML files.

I am currently researching the right configuration for production deployments, and accidentally found out that we currently run with FACELETS_REFRESH_PERIOD=1 even in production, which is obviously not a good idea.

This lead to the question: What is the default value for this parameter?

Ideally, I'd like to just omit FACELETS_REFRESH_PERIOD from our production config for simplicity's sake, and hoped it would use a "safe" default value of -1. However, this does not seem to be the case, because without the parameter, refreshing seems to be enabled (with both Mojarra and MyFaces).

I checked the JSF spec, and while it describes the parameter, it does not give a default. Is this a deliberate omission in the spec?

sleske
  • 81,358
  • 34
  • 189
  • 227

1 Answers1

15

The default is implementation dependent.

Given that you're using Mojarra, you can find the default in the com.sun.faces.config.WebConfiguration class:

768         FaceletsDefaultRefreshPeriod(
769               "javax.faces.FACELETS_REFRESH_PERIOD",
770               "2"
771         )

(line numbers are from Mojarra 2.0.0)

The default is thus 2. I can't find this in any Mojarra documentation. It might be worth to post an issue report to Mojarra guys to better document it.

MyFaces has according its documentation also a default value of 2.


Update: From Mojarra 2.2.11, the default value is set to -1 if project stage is Production. See also issue 3788.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Yes, this really seems to be an (unfortunate) omission in the spec. Interestingly, there is an open feature request to automatically set the refresh period to -1 in production mode: http://java.net/jira/browse/JAVASERVERFACES-1434 , http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-936 That looks like the best solution (once it goes through). – sleske Nov 19 '12 at 16:01
  • 1
    @sleske looks like it went through at long lost. See http://jdevelopment.nl/jsf-23/#936 :) – dexter meyers Feb 25 '15 at 12:25
  • How would you change this value depending the project stage? – Rapster Jul 18 '18 at 08:40