@Override
public void process(ServletContext sc, DocumentInfo[] documentInfos)
throws Exception {
WebConfiguration config = WebConfiguration.getInstance(sc);
FacesContext context = FacesContext.getCurrentInstance();
for (int i = 0; i < documentInfos.length; i++) {
URI definingDocumentURI = documentInfos[i].getSourceURI();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing factory elements for document: ''{0}''",
definingDocumentURI));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
.getNamespaceURI();
NodeList flowDefinitions = document.getDocumentElement()
.getElementsByTagNameNS(namespace, FACES_FLOW_DEFINITION);
if (flowDefinitions != null && flowDefinitions.getLength() > 0) {
config.setHasFlows(true);
saveFlowDefinition(context, definingDocumentURI, document);
}
}
if (config.isHasFlows()) {
String optionValue = config.getOptionValue(WebConfiguration.WebContextInitParameter.ClientWindowMode);
boolean clientWindowNeedsEnabling = false;
if ("none".equals(optionValue)) {
clientWindowNeedsEnabling = true;
String featureName =
WebConfiguration.WebContextInitParameter.ClientWindowMode.getQualifiedName();
LOGGER.log(Level.WARNING,
"{0} was set to none, but Faces Flows requires {0} is enabled. Setting to ''url''.", new Object[]{featureName});
} else if (null == optionValue) {
clientWindowNeedsEnabling = true;
}
if (clientWindowNeedsEnabling) {
config.setOptionValue(WebConfiguration.WebContextInitParameter.ClientWindowMode, "url");
}
context.getApplication().subscribeToEvent(PostConstructApplicationEvent.class,
Application.class, new PerformDeferredFlowProcessing());
}