diff --git a/build.gradle b/build.gradle
index 58346dd2..c1978653 100644
--- a/build.gradle
+++ b/build.gradle
@@ -224,6 +224,7 @@ project('spring-faces') {
compile("com.sun.facelets:jsf-facelets:1.1.14", optional)
compile("com.sun.faces:jsf-api:2.1.7", provided)
compile("com.sun.faces:jsf-impl:2.1.7", provided)
+ compile("org.apache.myfaces.core:myfaces-impl:2.1.7", provided)
testCompile("log4j:log4j:$log4jVersion") { dep ->
optional dep
diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java
deleted file mode 100644
index e970c553..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2004-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.expression;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.PropertyResolver;
-
-/**
- * A JSF 1.1 {@link PropertyResolver} that delegates to a wrapped Unified EL resolver chain for property resolution.
- *
- * @author Jeremy Grelle
- * @deprecated Upgrade to JSF 2.0
- */
-@Deprecated
-public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
-
- private PropertyResolver nextResolver;
-
- private ELResolver delegate;
-
- public ELDelegatingPropertyResolver(PropertyResolver nextResolver, ELResolver delegate) {
- this.nextResolver = nextResolver;
- this.delegate = delegate;
- }
-
- public Class> getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- Class> type = elContext.getELResolver().getType(elContext, base, index);
- if (elContext.isPropertyResolved()) {
- return type;
- } else {
- return nextResolver.getType(base, index);
- }
- }
-
- public Class> getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- Class> type = elContext.getELResolver().getType(elContext, base, property);
- if (elContext.isPropertyResolved()) {
- return type;
- } else {
- return nextResolver.getType(base, property);
- }
- }
-
- public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- Object value = elContext.getELResolver().getValue(elContext, base, index);
- if (elContext.isPropertyResolved()) {
- return value;
- } else {
- return nextResolver.getValue(base, index);
- }
- }
-
- public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- Object value = elContext.getELResolver().getValue(elContext, base, property);
- if (elContext.isPropertyResolved()) {
- return value;
- } else {
- return nextResolver.getValue(base, property);
- }
- }
-
- public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- boolean readOnly = elContext.getELResolver().isReadOnly(elContext, base, index);
- if (elContext.isPropertyResolved()) {
- return readOnly;
- } else {
- return nextResolver.isReadOnly(base, index);
- }
- }
-
- public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- boolean readOnly = elContext.getELResolver().isReadOnly(elContext, base, property);
- if (elContext.isPropertyResolved()) {
- return readOnly;
- } else {
- return nextResolver.isReadOnly(base, property);
- }
- }
-
- public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- elContext.getELResolver().setValue(elContext, base, index, value);
- if (!elContext.isPropertyResolved()) {
- nextResolver.setValue(base, index, value);
- }
- }
-
- public void setValue(Object base, Object property, Object value) throws EvaluationException,
- PropertyNotFoundException {
- ELContext elContext = new SimpleELContext(delegate);
- elContext.getELResolver().setValue(elContext, base, property, value);
- if (!elContext.isPropertyResolved()) {
- nextResolver.setValue(base, property, value);
- }
- }
-
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java
deleted file mode 100644
index c3c75598..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2004-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.expression;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.VariableResolver;
-
-/**
- * A JSF 1.1 {@link VariableResolver} that delegates to a wrapped Unified EL resolver chain for variable resolution.
- *
- * @author Jeremy Grelle
- * @deprecated Upgrade to JSF 2.0
- */
-@Deprecated
-public abstract class ELDelegatingVariableResolver extends VariableResolver {
-
- private VariableResolver nextResolver;
-
- private ELResolver delegate;
-
- public ELDelegatingVariableResolver(VariableResolver nextResolver, ELResolver delegate) {
- this.nextResolver = nextResolver;
- this.delegate = delegate;
- }
-
- public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException {
- ELContext elContext = new SimpleELContext(delegate);
- Object result = elContext.getELResolver().getValue(elContext, null, name);
- if (elContext.isPropertyResolved()) {
- return result;
- } else {
- return nextResolver.resolveVariable(facesContext, name);
- }
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/SimpleELContext.java b/spring-faces/src/main/java/org/springframework/faces/expression/SimpleELContext.java
deleted file mode 100644
index 37b1cb64..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/expression/SimpleELContext.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2004-2008 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.expression;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-
-/**
- * A minimal {@link ELContext} implementation.
- *
- * @author Jeremy Grelle
- */
-class SimpleELContext extends ELContext {
-
- private ELResolver resolver;
-
- public SimpleELContext(ELResolver resolver) {
- this.resolver = resolver;
- }
-
- public ELResolver getELResolver() {
- return resolver;
- }
-
- public FunctionMapper getFunctionMapper() {
- return null;
- }
-
- public VariableMapper getVariableMapper() {
- return null;
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/package.html b/spring-faces/src/main/java/org/springframework/faces/expression/package.html
deleted file mode 100644
index 4bd2e6ab..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/expression/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
Support for adapting Unified EL resolvers to the JSF 1.1 API.
-
-
\ No newline at end of file
diff --git a/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java
index af79da0a..4e174e65 100644
--- a/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java
+++ b/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java
@@ -41,26 +41,26 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataM
}
public List getSelections() {
- return selections;
+ return this.selections;
}
public boolean isCurrentRowSelected() {
- return selections.contains(getRowData());
+ return this.selections.contains(getRowData());
}
public void selectAll() {
- selections.clear();
- selections.addAll(getWrappedData());
+ this.selections.clear();
+ this.selections.addAll(getWrappedData());
}
public void setCurrentRowSelected(boolean rowSelected) {
if (!isRowAvailable()) {
return;
}
- if (rowSelected && !selections.contains(getRowData())) {
- selections.add(getRowData());
+ if (rowSelected && !this.selections.contains(getRowData())) {
+ this.selections.add(getRowData());
} else if (!rowSelected) {
- selections.remove(getRowData());
+ this.selections.remove(getRowData());
}
}
@@ -70,8 +70,8 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataM
public void select(T rowData) {
Assert.isTrue((getWrappedData()).contains(rowData), "The object to select is not contained in this DataModel.");
- if (!selections.contains(rowData)) {
- selections.add(rowData);
+ if (!this.selections.contains(rowData)) {
+ this.selections.add(rowData);
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java
index cdc57b8c..499ff285 100644
--- a/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java
+++ b/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java
@@ -43,17 +43,17 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataMo
}
public List getSelections() {
- return selections;
+ return this.selections;
}
public boolean isCurrentRowSelected() {
- return selections.contains(getRowData());
+ return this.selections.contains(getRowData());
}
public void select(T rowData) {
Assert.isTrue((getWrappedData()).contains(rowData), "The object to select is not contained in this DataModel.");
- selections.clear();
- selections.add(rowData);
+ this.selections.clear();
+ this.selections.add(rowData);
}
public void selectAll() {
@@ -68,10 +68,10 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataMo
}
if (!rowSelected) {
- selections.remove(getRowData());
- } else if (rowSelected && !selections.contains(getRowData())) {
- selections.clear();
- selections.add(getRowData());
+ this.selections.remove(getRowData());
+ } else if (rowSelected && !this.selections.contains(getRowData())) {
+ this.selections.clear();
+ this.selections.add(getRowData());
}
}
@@ -81,8 +81,8 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataMo
}
public Object getSelectedRow() {
- if (selections.size() == 1) {
- return selections.get(0);
+ if (this.selections.size() == 1) {
+ return this.selections.get(0);
} else {
return null;
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java b/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java
index 76383b32..1db971ac 100644
--- a/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java
+++ b/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java
@@ -44,7 +44,7 @@ public class SelectionTrackingActionListener implements ActionListener {
private static final Log logger = LogFactory.getLog(FlowActionListener.class);
- private ActionListener delegate;
+ private final ActionListener delegate;
public SelectionTrackingActionListener(ActionListener delegate) {
this.delegate = delegate;
@@ -52,7 +52,7 @@ public class SelectionTrackingActionListener implements ActionListener {
public void processAction(ActionEvent event) throws AbortProcessingException {
trackSelection(event.getComponent());
- delegate.processAction(event);
+ this.delegate.processAction(event);
}
private void trackSelection(UIComponent component) {
diff --git a/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java
index 2b2f349b..5e8ba398 100644
--- a/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java
+++ b/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java
@@ -52,36 +52,36 @@ public class SerializableListDataModel extends DataModel implements Serial
}
public int getRowCount() {
- return data.size();
+ return this.data.size();
}
public T getRowData() {
Assert.isTrue(isRowAvailable(), getClass()
+ " is in an illegal state - no row is available at the current index.");
- return data.get(rowIndex);
+ return this.data.get(this.rowIndex);
}
public int getRowIndex() {
- return rowIndex;
+ return this.rowIndex;
}
public List getWrappedData() {
- return data;
+ return this.data;
}
public boolean isRowAvailable() {
- return rowIndex >= 0 && rowIndex < data.size();
+ return this.rowIndex >= 0 && this.rowIndex < this.data.size();
}
public void setRowIndex(int newRowIndex) {
if (newRowIndex < -1) {
throw new IllegalArgumentException("Illegal row index for " + getClass() + ": " + newRowIndex);
}
- int oldRowIndex = rowIndex;
- rowIndex = newRowIndex;
- if (data != null && oldRowIndex != rowIndex) {
+ int oldRowIndex = this.rowIndex;
+ this.rowIndex = newRowIndex;
+ if (this.data != null && oldRowIndex != this.rowIndex) {
Object row = isRowAvailable() ? getRowData() : null;
- DataModelEvent event = new DataModelEvent(this, rowIndex, row);
+ DataModelEvent event = new DataModelEvent(this, this.rowIndex, row);
DataModelListener[] listeners = getDataModelListeners();
for (DataModelListener listener : listeners) {
listener.rowSelected(event);
@@ -101,7 +101,7 @@ public class SerializableListDataModel extends DataModel implements Serial
}
public String toString() {
- return data.toString();
+ return this.data.toString();
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java b/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
index debe4fe7..ecd7f091 100644
--- a/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
+++ b/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
@@ -15,12 +15,10 @@
*/
package org.springframework.faces.mvc;
-import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf12;
import static org.springframework.faces.webflow.JsfRuntimeInformation.isPortletRequest;
import java.util.Map;
-import javax.faces.FactoryFinder;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
@@ -48,7 +46,7 @@ public class JsfView extends AbstractUrlBasedView {
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
- facesLifecycle = createFacesLifecycle();
+ this.facesLifecycle = createFacesLifecycle();
}
protected void renderMergedOutputModel(Map model, HttpServletRequest request,
@@ -59,11 +57,11 @@ public class JsfView extends AbstractUrlBasedView {
populateRequestMap(facesContext, model);
- JsfUtils.notifyBeforeListeners(PhaseId.RESTORE_VIEW, facesLifecycle, facesContext);
+ JsfUtils.notifyBeforeListeners(PhaseId.RESTORE_VIEW, this.facesLifecycle, facesContext);
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
- if (isAtLeastJsf12() && (!isPortletRequest(facesContext))) {
+ if (!isPortletRequest(facesContext)) {
viewHandler.initView(facesContext);
}
@@ -74,15 +72,15 @@ public class JsfView extends AbstractUrlBasedView {
facesContext.setViewRoot(viewRoot);
- JsfUtils.notifyAfterListeners(PhaseId.RESTORE_VIEW, facesLifecycle, facesContext);
+ JsfUtils.notifyAfterListeners(PhaseId.RESTORE_VIEW, this.facesLifecycle, facesContext);
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();
try {
- logger.debug("Asking faces lifecycle to render");
- facesLifecycle.render(facesContext);
+ this.logger.debug("Asking faces lifecycle to render");
+ this.facesLifecycle.render(facesContext);
} finally {
- logger.debug("View rendering complete");
+ this.logger.debug("View rendering complete");
facesContextHelper.releaseIfNecessary();
}
}
@@ -96,8 +94,7 @@ public class JsfView extends AbstractUrlBasedView {
}
private Lifecycle createFacesLifecycle() {
- LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
- .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ LifecycleFactory lifecycleFactory = JsfUtils.findFactory(LifecycleFactory.class);
return lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/security/AbstractAuthorizeTag.java b/spring-faces/src/main/java/org/springframework/faces/security/AbstractAuthorizeTag.java
index d427563b..7b18cd6f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/security/AbstractAuthorizeTag.java
+++ b/spring-faces/src/main/java/org/springframework/faces/security/AbstractAuthorizeTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,18 +47,18 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
*
* A base class for an <authorize> tag used to make Spring Security based authorization decisions.
*
- *
+ *
*
* This class is independent of tag rendering technology (JSP, Facelets). It treats tag attributes as simple strings
* (with the notable exception of the "access" attribute, which is always expected to contain a Spring EL expression).
* Therefore subclasses are expected to extract tag attribute values from the specific rendering technology, evaluate
* them as expressions if necessary, and use the result to set the String-based attributes of this class.
*
- *
+ *
* @author Francois Beausoleil
* @author Luke Taylor
* @author Rossen Stoyanchev
- *
+ *
* @since 2.2.0
*/
public abstract class AbstractAuthorizeTag {
@@ -97,9 +97,9 @@ public abstract class AbstractAuthorizeTag {
*
ifAllGranted, ifAnyGranted, ifNotGranted
*
* The above combinations are mutually exclusive and evaluated in the given order.
- *
+ *
* @return the result of the authorization decision
- *
+ *
* @throws IOException
*/
public boolean authorize() throws IOException {
@@ -122,7 +122,7 @@ public abstract class AbstractAuthorizeTag {
/**
* Make an authorization decision by considering ifAllGranted, ifAnyGranted, and ifNotGranted. All 3 or any
* combination can be provided. All provided attributes must evaluate to true.
- *
+ *
* @return the result of the authorization decision
*/
public boolean authorizeUsingGrantedAuthorities() {
@@ -162,9 +162,9 @@ public abstract class AbstractAuthorizeTag {
/**
* Make an authorization decision based on a Spring EL expression. See the "Expression-Based Access Control" chapter
* in Spring Security for details on what expressions can be used.
- *
+ *
* @return the result of the authorization decision
- *
+ *
* @throws IOException
*/
public boolean authorizeUsingAccessExpression() throws IOException {
@@ -197,9 +197,9 @@ public abstract class AbstractAuthorizeTag {
/**
* Make an authorization decision based on the URL and HTTP method attributes. True is returned if the user is
* allowed to access the given URL as defined.
- *
+ *
* @return the result of the authorization decision
- *
+ *
* @throws IOException
*/
public boolean authorizeUsingUrlCheck() throws IOException {
@@ -209,7 +209,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getAccess() {
- return access;
+ return this.access;
}
public void setAccess(String access) {
@@ -217,7 +217,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getUrl() {
- return url;
+ return this.url;
}
public void setUrl(String url) {
@@ -225,7 +225,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getMethod() {
- return method;
+ return this.method;
}
public void setMethod(String method) {
@@ -233,7 +233,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getIfAllGranted() {
- return ifAllGranted;
+ return this.ifAllGranted;
}
public void setIfAllGranted(String ifAllGranted) {
@@ -241,7 +241,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getIfAnyGranted() {
- return ifAnyGranted;
+ return this.ifAnyGranted;
}
public void setIfAnyGranted(String ifAnyGranted) {
@@ -249,7 +249,7 @@ public abstract class AbstractAuthorizeTag {
}
public String getIfNotGranted() {
- return ifNotGranted;
+ return this.ifNotGranted;
}
public void setIfNotGranted(String ifNotGranted) {
diff --git a/spring-faces/src/main/java/org/springframework/faces/security/FaceletsAuthorizeTagHandler.java b/spring-faces/src/main/java/org/springframework/faces/security/FaceletsAuthorizeTagHandler.java
index 4ed8fa91..e885eb65 100644
--- a/spring-faces/src/main/java/org/springframework/faces/security/FaceletsAuthorizeTagHandler.java
+++ b/spring-faces/src/main/java/org/springframework/faces/security/FaceletsAuthorizeTagHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
*
ifAllGranted, ifAnyGranted, ifNotGranted
*
* The var attribute can be used to store the result of the authorization decision for later use in the view.
- *
+ *
* @author Rossen Stoyanchev
* @since 2.2.0
* @see FaceletsAuthorizeTag
@@ -71,8 +71,8 @@ public class FaceletsAuthorizeTagHandler extends TagHandler {
return;
}
- FaceletsAuthorizeTag authorizeTag = new FaceletsAuthorizeTag(faceletContext, access, url, method, ifAllGranted,
- ifAnyGranted, ifNotGranted);
+ FaceletsAuthorizeTag authorizeTag = new FaceletsAuthorizeTag(faceletContext, this.access, this.url, this.method, this.ifAllGranted,
+ this.ifAnyGranted, this.ifNotGranted);
boolean isAuthorized = authorizeTag.authorize();
@@ -81,7 +81,7 @@ public class FaceletsAuthorizeTagHandler extends TagHandler {
}
if (this.var != null) {
- faceletContext.setAttribute(var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
+ faceletContext.setAttribute(this.var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/security/Jsf12FaceletsAuthorizeTagHandler.java b/spring-faces/src/main/java/org/springframework/faces/security/Jsf12FaceletsAuthorizeTagHandler.java
index 180ab85a..abfc7665 100644
--- a/spring-faces/src/main/java/org/springframework/faces/security/Jsf12FaceletsAuthorizeTagHandler.java
+++ b/spring-faces/src/main/java/org/springframework/faces/security/Jsf12FaceletsAuthorizeTagHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import com.sun.facelets.tag.TagHandler;
*
ifAllGranted, ifAnyGranted, ifNotGranted
*
* The var attribute can be used to store the result of the authorization decision for later use in the view.
- *
+ *
* @author Rossen Stoyanchev
* @since 2.2.0
* @see Jsf12FaceletsAuthorizeTag
@@ -72,8 +72,8 @@ public class Jsf12FaceletsAuthorizeTagHandler extends TagHandler {
return;
}
- Jsf12FaceletsAuthorizeTag authorizeTag = new Jsf12FaceletsAuthorizeTag(faceletContext, access, url, method,
- ifAllGranted, ifAnyGranted, ifNotGranted);
+ Jsf12FaceletsAuthorizeTag authorizeTag = new Jsf12FaceletsAuthorizeTag(faceletContext, this.access, this.url, this.method,
+ this.ifAllGranted, this.ifAnyGranted, this.ifNotGranted);
boolean isAuthorized = authorizeTag.authorize();
@@ -82,7 +82,7 @@ public class Jsf12FaceletsAuthorizeTagHandler extends TagHandler {
}
if (this.var != null) {
- faceletContext.setAttribute(var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
+ faceletContext.setAttribute(this.var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/support/LifecycleWrapper.java b/spring-faces/src/main/java/org/springframework/faces/support/LifecycleWrapper.java
new file mode 100644
index 00000000..de20e310
--- /dev/null
+++ b/spring-faces/src/main/java/org/springframework/faces/support/LifecycleWrapper.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.faces.support;
+
+import javax.faces.FacesException;
+import javax.faces.FacesWrapper;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * Provides a simple implementation of {@link Lifecycle} that can be subclassed by developers wishing to provide
+ * specialized behavior to an existing {@link Lifecycle instance} . The default implementation of all methods is to call
+ * through to the wrapped {@link Lifecycle}.
+ *
+ * @author Phillip Webb
+ *
+ * @since 2.4
+ */
+public abstract class LifecycleWrapper extends Lifecycle implements FacesWrapper {
+
+ public abstract Lifecycle getWrapped();
+
+ public void addPhaseListener(PhaseListener listener) {
+ getWrapped().addPhaseListener(listener);
+ }
+
+ public void execute(FacesContext context) throws FacesException {
+ getWrapped().execute(context);
+ }
+
+ public PhaseListener[] getPhaseListeners() {
+ return getWrapped().getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener listener) {
+ getWrapped().removePhaseListener(listener);
+ }
+
+ public void render(FacesContext context) throws FacesException {
+ getWrapped().render(context);
+ }
+}
diff --git a/spring-faces/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java b/spring-faces/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java
index e74541f4..6aa3523d 100644
--- a/spring-faces/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java
+++ b/spring-faces/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,12 +26,13 @@ import org.apache.commons.logging.LogFactory;
* {@link PhaseListener} that logs the execution of the individual phases of the JSF lifecycle. Useful during JSF
* application development in order to detect unreported JSF errors that cause the lifecycle to short-circuit. Turn
* logging level to DEBUG to see its output.
- *
+ *
* @author Jeremy Grelle
*/
+@SuppressWarnings("serial")
public class RequestLoggingPhaseListener implements PhaseListener {
- private Log logger = LogFactory.getLog(RequestLoggingPhaseListener.class);
+ private static final Log logger = LogFactory.getLog(RequestLoggingPhaseListener.class);
public void afterPhase(PhaseEvent event) {
// no-op
diff --git a/spring-faces/src/main/java/org/springframework/faces/support/ResponseStateManagerWrapper.java b/spring-faces/src/main/java/org/springframework/faces/support/ResponseStateManagerWrapper.java
new file mode 100644
index 00000000..1bc557c2
--- /dev/null
+++ b/spring-faces/src/main/java/org/springframework/faces/support/ResponseStateManagerWrapper.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2010-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.faces.support;
+
+import java.io.IOException;
+
+import javax.faces.FacesWrapper;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.context.FacesContext;
+import javax.faces.render.ResponseStateManager;
+
+/**
+ * Provides a simple implementation of {@link ResponseStateManager} that can be subclassed by developers wishing to
+ * provide specialized behavior to an existing {@link ResponseStateManager instance} . The default implementation of all
+ * methods is to call through to the wrapped {@link ResponseStateManager}.
+ *
+ * @author Phillip Webb
+ *
+ * @since 2.4
+ */
+@SuppressWarnings("deprecation")
+public abstract class ResponseStateManagerWrapper extends ResponseStateManager implements
+ FacesWrapper {
+
+ public abstract ResponseStateManager getWrapped();
+
+ @Override
+ public void writeState(FacesContext context, Object state) throws IOException {
+ getWrapped().writeState(context, state);
+ }
+
+ @Override
+ @Deprecated
+ public void writeState(FacesContext context, SerializedView state) throws IOException {
+ getWrapped().writeState(context, state);
+ }
+
+ @Override
+ public Object getState(FacesContext context, String viewId) {
+ return getWrapped().getState(context, viewId);
+ }
+
+ @Override
+ @Deprecated
+ public Object getTreeStructureToRestore(FacesContext context, String viewId) {
+ return getWrapped().getTreeStructureToRestore(context, viewId);
+ }
+
+ @Override
+ @Deprecated
+ public Object getComponentStateToRestore(FacesContext context) {
+ return getWrapped().getComponentStateToRestore(context);
+ }
+
+ @Override
+ public boolean isPostback(FacesContext context) {
+ return getWrapped().isPostback(context);
+ }
+
+ @Override
+ public String getViewState(FacesContext context, Object state) {
+ return getWrapped().getViewState(context, state);
+ }
+}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java
index 172fc635..07b8da2f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java
@@ -60,7 +60,7 @@ public class AjaxViewRoot extends DelegatingViewRoot {
protected static final String PROCESS_ALL = "*";
- private List events = new ArrayList();
+ private final List events = new ArrayList();
private String[] processIds;
@@ -72,7 +72,7 @@ public class AjaxViewRoot extends DelegatingViewRoot {
public AjaxViewRoot(UIViewRoot original) {
super(original);
- renderIdsExpr = FacesContext.getCurrentInstance().getApplication().createValueBinding(RENDER_IDS_EXPRESSION);
+ this.renderIdsExpr = FacesContext.getCurrentInstance().getApplication().createValueBinding(RENDER_IDS_EXPRESSION);
if (!StringUtils.hasText(original.getId())) {
original.setId(createUniqueId());
}
@@ -87,7 +87,7 @@ public class AjaxViewRoot extends DelegatingViewRoot {
public void queueEvent(FacesEvent event) {
Assert.notNull(event, "Cannot queue a null event.");
- events.add(event);
+ this.events.add(event);
}
public void encodeAll(FacesContext context) throws IOException {
@@ -162,30 +162,30 @@ public class AjaxViewRoot extends DelegatingViewRoot {
// subclassing hooks
protected String[] getProcessIds() {
- if (processIds == null) {
+ if (this.processIds == null) {
FacesContext context = FacesContext.getCurrentInstance();
String processIdsParam = context.getExternalContext().getRequestParameterMap().get(PROCESS_IDS_PARAM);
if (StringUtils.hasText(processIdsParam) && processIdsParam.indexOf(PROCESS_ALL) != -1) {
- processIds = new String[] { getOriginalViewRoot().getClientId(context) };
+ this.processIds = new String[] { getOriginalViewRoot().getClientId(context) };
} else {
- processIds = StringUtils.delimitedListToStringArray(processIdsParam, ",", " ");
- processIds = removeNestedChildren(context, processIds);
+ this.processIds = StringUtils.delimitedListToStringArray(processIdsParam, ",", " ");
+ this.processIds = removeNestedChildren(context, this.processIds);
}
}
- return processIds;
+ return this.processIds;
}
protected String[] getRenderIds() {
- if (renderIds == null) {
+ if (this.renderIds == null) {
FacesContext context = FacesContext.getCurrentInstance();
- renderIds = (String[]) renderIdsExpr.getValue(context);
- if (renderIds == null || renderIds.length == 0) {
- renderIds = getProcessIds();
+ this.renderIds = (String[]) this.renderIdsExpr.getValue(context);
+ if (this.renderIds == null || this.renderIds.length == 0) {
+ this.renderIds = getProcessIds();
} else {
- renderIds = removeNestedChildren(context, renderIds);
+ this.renderIds = removeNestedChildren(context, this.renderIds);
}
}
- return renderIds;
+ return this.renderIds;
}
// internal helpers
@@ -260,12 +260,12 @@ public class AjaxViewRoot extends DelegatingViewRoot {
private void broadCastEvents(FacesContext context, PhaseId phaseId) {
List processedEvents = new ArrayList();
- if (events.size() == 0) {
+ if (this.events.size() == 0) {
return;
}
boolean abort = false;
int phaseIdOrdinal = phaseId.getOrdinal();
- for (FacesEvent event : events) {
+ for (FacesEvent event : this.events) {
int ordinal = event.getPhaseId().getOrdinal();
if (ordinal == PhaseId.ANY_PHASE.getOrdinal() || ordinal == phaseIdOrdinal) {
UIComponent source = event.getComponent();
@@ -279,9 +279,9 @@ public class AjaxViewRoot extends DelegatingViewRoot {
}
}
if (abort) {
- events.clear();
+ this.events.clear();
} else {
- events.removeAll(processedEvents);
+ this.events.removeAll(processedEvents);
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java
index 606c908f..fcf4ac4e 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java
@@ -34,14 +34,14 @@ public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer {
private Map attributeCallbacks;
- private RenderAttributeCallback idCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback idCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
writer.writeAttribute(attribute, component.getClientId(context), property);
}
};
- private RenderAttributeCallback disabledCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback disabledCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
if (Boolean.TRUE.equals(attributeValue)) {
@@ -51,12 +51,12 @@ public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer {
};
protected Map getAttributeCallbacks(UIComponent component) {
- if (attributeCallbacks == null) {
- attributeCallbacks = new HashMap();
- attributeCallbacks.put("id", idCallback);
- attributeCallbacks.put("name", idCallback);
- attributeCallbacks.put("disabled", disabledCallback);
+ if (this.attributeCallbacks == null) {
+ this.attributeCallbacks = new HashMap();
+ this.attributeCallbacks.put("id", this.idCallback);
+ this.attributeCallbacks.put("name", this.idCallback);
+ this.attributeCallbacks.put("disabled", this.disabledCallback);
}
- return attributeCallbacks;
+ return this.attributeCallbacks;
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java
index 94c2c2ca..59073111 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java
@@ -45,7 +45,7 @@ abstract class BaseHtmlTagRenderer extends Renderer {
* Default {@link RenderAttributeCallback} that just renders the tag attribute as a pass-through value if the value
* is not null.
*/
- private RenderAttributeCallback defaultRenderAttributeCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback defaultRenderAttributeCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
if (attributeValue != null) {
@@ -79,7 +79,7 @@ abstract class BaseHtmlTagRenderer extends Renderer {
}
Object attributeValue = component.getAttributes().get(property);
- RenderAttributeCallback callback = defaultRenderAttributeCallback;
+ RenderAttributeCallback callback = this.defaultRenderAttributeCallback;
if (getAttributeCallbacks(null).containsKey(attribute)) {
callback = getAttributeCallbacks(component).get(attribute);
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptComponentRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptComponentRenderer.java
index 3a9540a1..66711db3 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptComponentRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptComponentRenderer.java
@@ -32,14 +32,14 @@ import org.springframework.faces.webflow.JsfUtils;
*/
public abstract class BaseSpringJavascriptComponentRenderer extends BaseComponentRenderer {
- private String springJsResourceUri = "/spring/Spring.js";
+ private final String springJsResourceUri = "/spring/Spring.js";
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component);
if (!JsfUtils.isAsynchronousFlowRequest()) {
- ResourceHelper.renderScriptLink(context, springJsResourceUri);
+ ResourceHelper.renderScriptLink(context, this.springJsResourceUri);
}
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptDecorationRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptDecorationRenderer.java
index 1158f54b..6a08956f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptDecorationRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseSpringJavascriptDecorationRenderer.java
@@ -26,12 +26,12 @@ import org.springframework.faces.webflow.JsfUtils;
public abstract class BaseSpringJavascriptDecorationRenderer extends Renderer {
- private String springJsResourceUri = "/spring/Spring.js";
+ private final String springJsResourceUri = "/spring/Spring.js";
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!JsfUtils.isAsynchronousFlowRequest()) {
- ResourceHelper.renderScriptLink(context, springJsResourceUri);
+ ResourceHelper.renderScriptLink(context, this.springJsResourceUri);
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java b/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java
index 7a827822..354a98f3 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java
@@ -40,14 +40,14 @@ import javax.faces.event.PhaseListener;
*/
public abstract class DelegatingViewRoot extends UIViewRoot {
- private UIViewRoot original;
+ private final UIViewRoot original;
public DelegatingViewRoot(UIViewRoot original) {
this.original = original;
}
public UIViewRoot getOriginalViewRoot() {
- return original;
+ return this.original;
}
/**
@@ -55,7 +55,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#addPhaseListener(javax.faces.event.PhaseListener)
*/
public void addPhaseListener(PhaseListener phaseListener) {
- original.addPhaseListener(phaseListener);
+ this.original.addPhaseListener(phaseListener);
}
/**
@@ -64,14 +64,14 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException {
- original.broadcast(event);
+ this.original.broadcast(event);
}
/**
* @see javax.faces.component.UIViewRoot#createUniqueId()
*/
public String createUniqueId() {
- return (original != null) ? original.createUniqueId() : null;
+ return (this.original != null) ? this.original.createUniqueId() : null;
}
/**
@@ -79,7 +79,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
*/
public void decode(FacesContext context) {
- original.decode(context);
+ this.original.decode(context);
}
/**
@@ -88,7 +88,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponent#encodeAll(javax.faces.context.FacesContext)
*/
public void encodeAll(FacesContext context) throws IOException {
- original.encodeAll(context);
+ this.original.encodeAll(context);
}
/**
@@ -97,7 +97,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
- original.encodeBegin(context);
+ this.original.encodeBegin(context);
}
/**
@@ -106,7 +106,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
*/
public void encodeChildren(FacesContext context) throws IOException {
- original.encodeChildren(context);
+ this.original.encodeChildren(context);
}
/**
@@ -115,7 +115,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#encodeEnd(javax.faces.context.FacesContext)
*/
public void encodeEnd(FacesContext context) throws IOException {
- original.encodeEnd(context);
+ this.original.encodeEnd(context);
}
/**
@@ -123,42 +123,42 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#findComponent(java.lang.String)
*/
public UIComponent findComponent(String expr) {
- return original.findComponent(expr);
+ return this.original.findComponent(expr);
}
/**
* @see javax.faces.component.UIViewRoot#getAfterPhaseListener()
*/
public MethodExpression getAfterPhaseListener() {
- return original.getAfterPhaseListener();
+ return this.original.getAfterPhaseListener();
}
/**
* @see javax.faces.component.UIComponentBase#getAttributes()
*/
public Map getAttributes() {
- return original.getAttributes();
+ return this.original.getAttributes();
}
/**
* @see javax.faces.component.UIViewRoot#getBeforePhaseListener()
*/
public MethodExpression getBeforePhaseListener() {
- return original.getBeforePhaseListener();
+ return this.original.getBeforePhaseListener();
}
/**
* @see javax.faces.component.UIComponentBase#getChildCount()
*/
public int getChildCount() {
- return original.getChildCount();
+ return this.original.getChildCount();
}
/**
* @see javax.faces.component.UIComponentBase#getChildren()
*/
public List getChildren() {
- return original.getChildren();
+ return this.original.getChildren();
}
/**
@@ -166,7 +166,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#getClientId(javax.faces.context.FacesContext)
*/
public String getClientId(FacesContext context) {
- return original.getClientId(context);
+ return this.original.getClientId(context);
}
/**
@@ -174,7 +174,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponent#getContainerClientId(javax.faces.context.FacesContext)
*/
public String getContainerClientId(FacesContext ctx) {
- return original.getContainerClientId(ctx);
+ return this.original.getContainerClientId(ctx);
}
/**
@@ -182,77 +182,77 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#getFacet(java.lang.String)
*/
public UIComponent getFacet(String name) {
- return original.getFacet(name);
+ return this.original.getFacet(name);
}
/**
* @see javax.faces.component.UIComponentBase#getFacetCount()
*/
public int getFacetCount() {
- return original.getFacetCount();
+ return this.original.getFacetCount();
}
/**
* @see javax.faces.component.UIComponentBase#getFacets()
*/
public Map getFacets() {
- return original.getFacets();
+ return this.original.getFacets();
}
/**
* @see javax.faces.component.UIComponentBase#getFacetsAndChildren()
*/
public Iterator getFacetsAndChildren() {
- return original.getFacetsAndChildren();
+ return this.original.getFacetsAndChildren();
}
/**
* @see javax.faces.component.UIViewRoot#getFamily()
*/
public String getFamily() {
- return original.getFamily();
+ return this.original.getFamily();
}
/**
* @see javax.faces.component.UIComponentBase#getId()
*/
public String getId() {
- return original.getId();
+ return this.original.getId();
}
/**
* @see javax.faces.component.UIViewRoot#getLocale()
*/
public Locale getLocale() {
- return original.getLocale();
+ return this.original.getLocale();
}
/**
* @see javax.faces.component.UIComponentBase#getParent()
*/
public UIComponent getParent() {
- return original.getParent();
+ return this.original.getParent();
}
/**
* @see javax.faces.component.UIComponentBase#getRendererType()
*/
public String getRendererType() {
- return original.getRendererType();
+ return this.original.getRendererType();
}
/**
* @see javax.faces.component.UIViewRoot#getRenderKitId()
*/
public String getRenderKitId() {
- return original.getRenderKitId();
+ return this.original.getRenderKitId();
}
/**
* @see javax.faces.component.UIComponentBase#getRendersChildren()
*/
public boolean getRendersChildren() {
- return original.getRendersChildren();
+ return this.original.getRendersChildren();
}
/**
@@ -261,7 +261,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#getValueBinding(java.lang.String)
*/
public ValueBinding getValueBinding(String name) {
- return original.getValueBinding(name);
+ return this.original.getValueBinding(name);
}
/**
@@ -269,14 +269,14 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponent#getValueExpression(java.lang.String)
*/
public ValueExpression getValueExpression(String name) {
- return original.getValueExpression(name);
+ return this.original.getValueExpression(name);
}
/**
* @see javax.faces.component.UIViewRoot#getViewId()
*/
public String getViewId() {
- return original.getViewId();
+ return this.original.getViewId();
}
/**
@@ -289,28 +289,28 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
*/
public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
throws FacesException {
- return original.invokeOnComponent(context, clientId, callback);
+ return this.original.invokeOnComponent(context, clientId, callback);
}
/**
* @see javax.faces.component.UIComponentBase#isRendered()
*/
public boolean isRendered() {
- return original.isRendered();
+ return this.original.isRendered();
}
/**
* @see javax.faces.component.UIComponentBase#isTransient()
*/
public boolean isTransient() {
- return original.isTransient();
+ return this.original.isTransient();
}
/**
* @see javax.faces.component.UIViewRoot#processApplication(javax.faces.context.FacesContext)
*/
public void processApplication(FacesContext context) {
- original.processApplication(context);
+ this.original.processApplication(context);
}
/**
@@ -318,7 +318,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#processDecodes(javax.faces.context.FacesContext)
*/
public void processDecodes(FacesContext context) {
- original.processDecodes(context);
+ this.original.processDecodes(context);
}
/**
@@ -328,7 +328,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* java.lang.Object)
*/
public void processRestoreState(FacesContext context, Object state) {
- original.processRestoreState(context, state);
+ this.original.processRestoreState(context, state);
}
/**
@@ -336,7 +336,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#processSaveState(javax.faces.context.FacesContext)
*/
public Object processSaveState(FacesContext context) {
- return original.processSaveState(context);
+ return this.original.processSaveState(context);
}
/**
@@ -344,7 +344,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#processUpdates(javax.faces.context.FacesContext)
*/
public void processUpdates(FacesContext context) {
- original.processUpdates(context);
+ this.original.processUpdates(context);
}
/**
@@ -352,7 +352,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#processValidators(javax.faces.context.FacesContext)
*/
public void processValidators(FacesContext context) {
- original.processValidators(context);
+ this.original.processValidators(context);
}
/**
@@ -360,7 +360,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#queueEvent(javax.faces.event.FacesEvent)
*/
public void queueEvent(FacesEvent event) {
- original.queueEvent(event);
+ this.original.queueEvent(event);
}
/**
@@ -368,7 +368,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#removePhaseListener(javax.faces.event.PhaseListener)
*/
public void removePhaseListener(PhaseListener phaseListener) {
- original.removePhaseListener(phaseListener);
+ this.original.removePhaseListener(phaseListener);
}
/**
@@ -377,7 +377,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#restoreState(javax.faces.context.FacesContext, java.lang.Object)
*/
public void restoreState(FacesContext facesContext, Object state) {
- original.restoreState(facesContext, state);
+ this.original.restoreState(facesContext, state);
}
/**
@@ -385,7 +385,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#saveState(javax.faces.context.FacesContext)
*/
public Object saveState(FacesContext facesContext) {
- return original.saveState(facesContext);
+ return this.original.saveState(facesContext);
}
/**
@@ -393,7 +393,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#setAfterPhaseListener(javax.el.MethodExpression)
*/
public void setAfterPhaseListener(MethodExpression afterPhaseListener) {
- original.setAfterPhaseListener(afterPhaseListener);
+ this.original.setAfterPhaseListener(afterPhaseListener);
}
/**
@@ -401,7 +401,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#setBeforePhaseListener(javax.el.MethodExpression)
*/
public void setBeforePhaseListener(MethodExpression beforePhaseListener) {
- original.setBeforePhaseListener(beforePhaseListener);
+ this.original.setBeforePhaseListener(beforePhaseListener);
}
/**
@@ -410,8 +410,8 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
*/
public void setId(String id) {
// Test for null to deal with JSF setId on constructor
- if (original != null) {
- original.setId(id);
+ if (this.original != null) {
+ this.original.setId(id);
}
}
@@ -420,7 +420,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#setLocale(java.util.Locale)
*/
public void setLocale(Locale locale) {
- original.setLocale(locale);
+ this.original.setLocale(locale);
}
/**
@@ -428,7 +428,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
*/
public void setParent(UIComponent parent) {
- original.setParent(parent);
+ this.original.setParent(parent);
}
/**
@@ -436,7 +436,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setRendered(boolean)
*/
public void setRendered(boolean rendered) {
- original.setRendered(rendered);
+ this.original.setRendered(rendered);
}
/**
@@ -444,8 +444,8 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setRendererType(java.lang.String)
*/
public void setRendererType(String rendererType) {
- if (original != null) {
- original.setRendererType(rendererType);
+ if (this.original != null) {
+ this.original.setRendererType(rendererType);
}
}
@@ -454,7 +454,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#setRenderKitId(java.lang.String)
*/
public void setRenderKitId(String renderKitId) {
- original.setRenderKitId(renderKitId);
+ this.original.setRenderKitId(renderKitId);
}
/**
@@ -462,7 +462,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setTransient(boolean)
*/
public void setTransient(boolean transientFlag) {
- original.setTransient(transientFlag);
+ this.original.setTransient(transientFlag);
}
/**
@@ -472,7 +472,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String, javax.faces.el.ValueBinding)
*/
public void setValueBinding(String name, ValueBinding binding) {
- original.setValueBinding(name, binding);
+ this.original.setValueBinding(name, binding);
}
/**
@@ -481,7 +481,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
*/
public void setValueExpression(String name, ValueExpression expression) {
- original.setValueExpression(name, expression);
+ this.original.setValueExpression(name, expression);
}
/**
@@ -489,7 +489,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#setViewId(java.lang.String)
*/
public void setViewId(String viewId) {
- original.setViewId(viewId);
+ this.original.setViewId(viewId);
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java
index 9268fcef..1e7d0738 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java
@@ -42,8 +42,8 @@ public class DojoClientCurrencyValidator extends DojoWidget {
private String currency;
public String getCurrency() {
- if (currency != null) {
- return currency;
+ if (this.currency != null) {
+ return this.currency;
}
ValueBinding exp = getValueBinding("currency");
return exp != null ? (String) exp.getValue(getFacesContext()) : null;
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
index c9bb7582..9294019f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
@@ -51,7 +51,7 @@ public class DojoClientDateValidator extends DojoWidget {
if (child.getConverter() instanceof DateTimeConverter) {
return ((DateTimeConverter) child.getConverter()).getPattern();
}
- return datePattern;
+ return this.datePattern;
}
public void setDatePattern(String datePattern) {
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java
index 84f2f2c4..d3c45de3 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java
@@ -56,8 +56,8 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
private Boolean uppercase;
public Boolean getDisabled() {
- if (disabled != null) {
- return disabled;
+ if (this.disabled != null) {
+ return this.disabled;
}
ValueBinding exp = getValueBinding("disabled");
return exp != null ? (Boolean) exp.getValue(getFacesContext()) : null;
@@ -68,7 +68,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Boolean getIntermediateChanges() {
- return intermediateChanges;
+ return this.intermediateChanges;
}
public void setIntermediateChanges(Boolean intermediateChanges) {
@@ -76,7 +76,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Integer getTabIndex() {
- return tabIndex;
+ return this.tabIndex;
}
public void setTabIndex(Integer tabIndex) {
@@ -84,7 +84,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Boolean getRequired() {
- return required;
+ return this.required;
}
public void setRequired(Boolean required) {
@@ -92,8 +92,8 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public String getPromptMessage() {
- if (promptMessage != null) {
- return promptMessage;
+ if (this.promptMessage != null) {
+ return this.promptMessage;
}
ValueBinding exp = getValueBinding("promptMessage");
return exp != null ? (String) exp.getValue(getFacesContext()) : null;
@@ -104,8 +104,8 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public String getInvalidMessage() {
- if (invalidMessage != null) {
- return invalidMessage;
+ if (this.invalidMessage != null) {
+ return this.invalidMessage;
}
ValueBinding exp = getValueBinding("invalidMessage");
return exp != null ? (String) exp.getValue(getFacesContext()) : null;
@@ -116,7 +116,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public String getConstraints() {
- return constraints;
+ return this.constraints;
}
public void setConstraints(String constraints) {
@@ -124,7 +124,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public String getRegExp() {
- return regExp;
+ return this.regExp;
}
public void setRegExp(String regExp) {
@@ -132,7 +132,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public String getRegExpGen() {
- return regExpGen;
+ return this.regExpGen;
}
public void setRegExpGen(String regExpGen) {
@@ -140,7 +140,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Boolean getLowercase() {
- return lowercase;
+ return this.lowercase;
}
public void setLowercase(Boolean lowercase) {
@@ -148,7 +148,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Boolean getUppercase() {
- return uppercase;
+ return this.uppercase;
}
public void setUppercase(Boolean uppercase) {
@@ -156,7 +156,7 @@ public abstract class DojoWidget extends SpringJavascriptElementDecoration {
}
public Boolean getPropercase() {
- return propercase;
+ return this.propercase;
}
public void setPropercase(Boolean propercase) {
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java
index 67700f10..1360d24c 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java
@@ -55,7 +55,7 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
private Map attributeCallbacks;
- private RenderAttributeCallback onclickCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback onclickCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
@@ -93,12 +93,12 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
};
protected Map getAttributeCallbacks(UIComponent component) {
- if (attributeCallbacks == null) {
- attributeCallbacks = new HashMap();
- attributeCallbacks.putAll(super.getAttributeCallbacks(component));
- attributeCallbacks.put("onclick", onclickCallback);
+ if (this.attributeCallbacks == null) {
+ this.attributeCallbacks = new HashMap();
+ this.attributeCallbacks.putAll(super.getAttributeCallbacks(component));
+ this.attributeCallbacks.put("onclick", this.onclickCallback);
}
- return attributeCallbacks;
+ return this.attributeCallbacks;
}
/**
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java
index 9c4b352c..9006cec2 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java
@@ -69,14 +69,14 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
private Map attributeCallbacks;
- private RenderAttributeCallback hrefCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback hrefCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
writer.writeAttribute(attribute, "#", property);
}
};
- private RenderAttributeCallback classCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback classCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
String classToAdd = "progressiveLink";
@@ -89,7 +89,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
}
};
- private RenderAttributeCallback noOpCallback = new RenderAttributeCallback() {
+ private final RenderAttributeCallback noOpCallback = new RenderAttributeCallback() {
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
@@ -194,14 +194,14 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
}
protected Map getAttributeCallbacks(UIComponent component) {
- if (attributeCallbacks == null) {
- attributeCallbacks = new HashMap();
- attributeCallbacks.putAll(super.getAttributeCallbacks(component));
- attributeCallbacks.put("href", hrefCallback);
- attributeCallbacks.put("class", classCallback);
- attributeCallbacks.put("type", noOpCallback);
+ if (this.attributeCallbacks == null) {
+ this.attributeCallbacks = new HashMap();
+ this.attributeCallbacks.putAll(super.getAttributeCallbacks(component));
+ this.attributeCallbacks.put("href", this.hrefCallback);
+ this.attributeCallbacks.put("class", this.classCallback);
+ this.attributeCallbacks.put("type", this.noOpCallback);
}
- return attributeCallbacks;
+ return this.attributeCallbacks;
}
protected String getOnClickNoAjax(FacesContext context, UIComponent component) {
@@ -241,81 +241,81 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
private class DoubleQuoteEscapingWriter extends ResponseWriter {
- private ResponseWriter original;
+ private final ResponseWriter original;
- private ResponseWriter clonedWriter;
+ private final ResponseWriter clonedWriter;
- private StringWriter buffer = new StringWriter();
+ private final StringWriter buffer = new StringWriter();
public DoubleQuoteEscapingWriter(ResponseWriter original) {
this.original = original;
- this.clonedWriter = original.cloneWithWriter(buffer);
+ this.clonedWriter = original.cloneWithWriter(this.buffer);
}
public String escapeResult() {
- String result = buffer.toString();
+ String result = this.buffer.toString();
result = result.replaceAll("\\\"", "\\\\\"");
return result;
}
public ResponseWriter cloneWithWriter(Writer arg0) {
- return clonedWriter.cloneWithWriter(arg0);
+ return this.clonedWriter.cloneWithWriter(arg0);
}
public void endDocument() throws IOException {
- clonedWriter.endDocument();
+ this.clonedWriter.endDocument();
}
public void endElement(String arg0) throws IOException {
- clonedWriter.endElement(arg0);
+ this.clonedWriter.endElement(arg0);
}
public void flush() throws IOException {
- clonedWriter.flush();
+ this.clonedWriter.flush();
}
public String getCharacterEncoding() {
- return clonedWriter.getCharacterEncoding();
+ return this.clonedWriter.getCharacterEncoding();
}
public String getContentType() {
- return clonedWriter.getContentType();
+ return this.clonedWriter.getContentType();
}
public void startDocument() throws IOException {
- clonedWriter.startDocument();
+ this.clonedWriter.startDocument();
}
public void startElement(String arg0, UIComponent arg1) throws IOException {
- clonedWriter.startElement(arg0, arg1);
+ this.clonedWriter.startElement(arg0, arg1);
}
public void writeAttribute(String arg0, Object arg1, String arg2) throws IOException {
- clonedWriter.writeAttribute(arg0, arg1, arg2);
+ this.clonedWriter.writeAttribute(arg0, arg1, arg2);
}
public void writeComment(Object arg0) throws IOException {
- clonedWriter.writeComment(arg0);
+ this.clonedWriter.writeComment(arg0);
}
public void writeText(char[] arg0, int arg1, int arg2) throws IOException {
- clonedWriter.writeText(arg0, arg1, arg2);
+ this.clonedWriter.writeText(arg0, arg1, arg2);
}
public void writeText(Object arg0, String arg1) throws IOException {
- clonedWriter.writeText(arg0, arg1);
+ this.clonedWriter.writeText(arg0, arg1);
}
public void writeURIAttribute(String arg0, Object arg1, String arg2) throws IOException {
- clonedWriter.writeURIAttribute(arg0, arg1, arg2);
+ this.clonedWriter.writeURIAttribute(arg0, arg1, arg2);
}
public void close() throws IOException {
- clonedWriter.close();
+ this.clonedWriter.close();
}
public void write(char[] cbuf, int off, int len) throws IOException {
- clonedWriter.write(cbuf, off, len);
+ this.clonedWriter.write(cbuf, off, len);
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java
index 80c2ab26..b1d97471 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java
@@ -41,7 +41,7 @@ public class ProgressiveUICommand extends UICommand {
private Boolean ajaxEnabled = true;
public String getType() {
- return type;
+ return this.type;
}
public void setType(String type) {
@@ -49,8 +49,8 @@ public class ProgressiveUICommand extends UICommand {
}
public Boolean getDisabled() {
- if (disabled != null) {
- return disabled;
+ if (this.disabled != null) {
+ return this.disabled;
}
ValueBinding vb = getValueBinding("disabled");
return vb != null ? (Boolean) vb.getValue(getFacesContext()) : false;
@@ -61,7 +61,7 @@ public class ProgressiveUICommand extends UICommand {
}
public Boolean getAjaxEnabled() {
- return ajaxEnabled;
+ return this.ajaxEnabled;
}
public void setAjaxEnabled(Boolean ajaxEnabled) {
@@ -84,18 +84,18 @@ public class ProgressiveUICommand extends UICommand {
public Object saveState(FacesContext context) {
Object[] values = new Object[4];
values[0] = super.saveState(context);
- values[1] = type;
- values[2] = disabled;
- values[3] = ajaxEnabled;
+ values[1] = this.type;
+ values[2] = this.disabled;
+ values[3] = this.ajaxEnabled;
return values;
}
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
- type = (String) values[1];
- disabled = (Boolean) values[2];
- ajaxEnabled = (Boolean) values[3];
+ this.type = (String) values[1];
+ this.disabled = (Boolean) values[2];
+ this.ajaxEnabled = (Boolean) values[3];
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java b/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java
deleted file mode 100644
index e721dc29..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2004-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.Principal;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.context.ExternalContext;
-
-class ExternalContextWrapper extends ExternalContext {
-
- protected ExternalContext delegate;
-
- public ExternalContextWrapper(ExternalContext delegate) {
- this.delegate = delegate;
- }
-
- public void dispatch(String path) throws IOException {
- delegate.dispatch(path);
- }
-
- public String encodeActionURL(String url) {
- return delegate.encodeActionURL(url);
- }
-
- public String encodeNamespace(String name) {
- return delegate.encodeNamespace(name);
- }
-
- public String encodeResourceURL(String url) {
- return delegate.encodeResourceURL(url);
- }
-
- public Map getApplicationMap() {
- return delegate.getApplicationMap();
- }
-
- public String getAuthType() {
- return delegate.getAuthType();
- }
-
- public Object getContext() {
- return delegate.getContext();
- }
-
- public String getInitParameter(String name) {
- return delegate.getInitParameter(name);
- }
-
- @SuppressWarnings("rawtypes")
- public Map getInitParameterMap() {
- return delegate.getInitParameterMap();
- }
-
- public String getRemoteUser() {
- return delegate.getRemoteUser();
- }
-
- public Object getRequest() {
- return delegate.getRequest();
- }
-
- public String getRequestCharacterEncoding() {
- return delegate.getRequestCharacterEncoding();
- }
-
- public String getRequestContentType() {
- return delegate.getRequestContentType();
- }
-
- public String getRequestContextPath() {
- return delegate.getRequestContextPath();
- }
-
- public Map getRequestCookieMap() {
- return delegate.getRequestCookieMap();
- }
-
- public Map getRequestHeaderMap() {
- return delegate.getRequestHeaderMap();
- }
-
- public Map getRequestHeaderValuesMap() {
- return delegate.getRequestHeaderValuesMap();
- }
-
- public Locale getRequestLocale() {
- return delegate.getRequestLocale();
- }
-
- public Iterator getRequestLocales() {
- return delegate.getRequestLocales();
- }
-
- public Map getRequestMap() {
- return delegate.getRequestMap();
- }
-
- public Map getRequestParameterMap() {
- return delegate.getRequestParameterMap();
- }
-
- public Iterator getRequestParameterNames() {
- return delegate.getRequestParameterNames();
- }
-
- public Map getRequestParameterValuesMap() {
- return delegate.getRequestParameterValuesMap();
- }
-
- public String getRequestPathInfo() {
- return delegate.getRequestPathInfo();
- }
-
- public String getRequestServletPath() {
- return delegate.getRequestServletPath();
- }
-
- public URL getResource(String path) throws MalformedURLException {
- return delegate.getResource(path);
- }
-
- public InputStream getResourceAsStream(String path) {
- return delegate.getResourceAsStream(path);
- }
-
- public Set getResourcePaths(String path) {
- return delegate.getResourcePaths(path);
- }
-
- public Object getResponse() {
- return delegate.getResponse();
- }
-
- public String getResponseCharacterEncoding() {
- return delegate.getResponseCharacterEncoding();
- }
-
- public String getResponseContentType() {
- return delegate.getResponseContentType();
- }
-
- public Object getSession(boolean create) {
- return delegate.getSession(create);
- }
-
- public Map getSessionMap() {
- return delegate.getSessionMap();
- }
-
- public Principal getUserPrincipal() {
- return delegate.getUserPrincipal();
- }
-
- public boolean isUserInRole(String role) {
- return delegate.isUserInRole(role);
- }
-
- public void log(String message, Throwable exception) {
- delegate.log(message, exception);
- }
-
- public void log(String message) {
- delegate.log(message);
- }
-
- public void redirect(String url) throws IOException {
- delegate.redirect(url);
- }
-
- public void setRequest(Object request) {
- delegate.setRequest(request);
- }
-
- public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException {
- delegate.setRequestCharacterEncoding(encoding);
- }
-
- public void setResponse(Object response) {
- delegate.setResponse(response);
- }
-
- public void setResponseCharacterEncoding(String encoding) {
- delegate.setResponseCharacterEncoding(encoding);
- }
-
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FacesContextHelper.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FacesContextHelper.java
index 6380acb3..0583e9e9 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FacesContextHelper.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FacesContextHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,46 +13,79 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.faces.webflow;
-import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import javax.faces.lifecycle.Lifecycle;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+
+import org.springframework.faces.webflow.context.portlet.PortletFacesContextImpl;
/**
- *
* Provides helper methods for getting a FacesContext that is suitable for use outside of Web Flow. Inside a running
* Flow session {@link FlowFacesContext} is typically used instead.
- *
- *
+ *
* @author Rossen Stoyanchev
+ * @author Phillip Webb
+ *
* @since 2.2.0
*/
public class FacesContextHelper {
private boolean release = false;
- public FacesContext getFacesContext(ServletContext servletContext, HttpServletRequest request,
- HttpServletResponse response) {
+ /**
+ * Returns a faces context that can be used outside of Web Flow. The context must be {@link #releaseIfNecessary()
+ * released} after use.
+ *
+ * @param context the native context
+ * @param request the native request
+ * @param response the native response
+ * @return a {@link FacesContext} instance.
+ * @see #release
+ */
+ public FacesContext getFacesContext(Object context, Object request, Object response) {
FacesContext facesContext = null;
if (FacesContext.getCurrentInstance() != null) {
facesContext = FacesContext.getCurrentInstance();
} else {
- FacesContextFactory factory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = factory.getFacesContext(servletContext, request, response, FlowLifecycle.newInstance());
- release = true;
+ facesContext = newDefaultInstance(context, request, response, FlowLifecycle.newInstance());
+ this.release = true;
}
return facesContext;
}
+ /**
+ * Release any previously {@link #getFacesContext obtained} {@link FacesContext} if necessary.
+ *
+ * @see #getFacesContext(Object, Object, Object)
+ */
public void releaseIfNecessary() {
if (release) {
FacesContext.getCurrentInstance().release();
}
}
+ /**
+ * Factory method that can be used to create a new default {@link FacesContext} instance for the running
+ * (Portlet/Servlet) environment.
+ *
+ * @param context the native context
+ * @param request the native request
+ * @param response the native response
+ * @param lifecycle the JSF lifecycle
+ * @return a new {@link FacesContext} instance
+ */
+ public static FacesContext newDefaultInstance(Object context, Object request, Object response, Lifecycle lifecycle) {
+ if (JsfRuntimeInformation.isPortletContext(context)) {
+ return new PortletFacesContextImpl((PortletContext) context, (PortletRequest) request, (PortletResponse) response);
+ }
+ FacesContextFactory facesContextFactory = JsfUtils.findFactory(FacesContextFactory.class);
+ return facesContextFactory.getFacesContext(context, request, response, lifecycle);
+ }
+
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FacesSpringELExpressionParser.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FacesSpringELExpressionParser.java
index 7ec2e51f..a949afc4 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FacesSpringELExpressionParser.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FacesSpringELExpressionParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser;
/**
- *
* A Spring EL {@link ExpressionParser} for use with JSF. Adds JSF specific Spring EL PropertyAccessors.
- *
*
* @author Rossen Stoyanchev
* @since 2.1
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java
index 7b7f76b4..58e74670 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java
@@ -19,7 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.faces.application.NavigationHandler;
-import javax.faces.component.ActionSource;
+import javax.faces.component.ActionSource2;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
@@ -40,15 +40,11 @@ import org.springframework.webflow.validation.WebFlowMessageCodesResolver;
/**
* The default {@link ActionListener} implementation to be used with Web Flow.
*
- *
* This implementation bypasses the JSF {@link NavigationHandler} mechanism to instead let the event be handled directly
* by Web Flow.
- *
- *
*
* Web Flow's model-level validation will be invoked here after an event has been detected if the event is not an
* immediate event.
- *
*
* @author Jeremy Grelle
*/
@@ -58,9 +54,9 @@ public class FlowActionListener implements ActionListener {
private static final String MESSAGES_ID = "messages";
- private ActionListener delegate;
+ private final ActionListener delegate;
- private MessageCodesResolver messageCodesResolver = new WebFlowMessageCodesResolver();
+ private final MessageCodesResolver messageCodesResolver = new WebFlowMessageCodesResolver();
public FlowActionListener(ActionListener delegate) {
this.delegate = delegate;
@@ -68,17 +64,17 @@ public class FlowActionListener implements ActionListener {
public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
if (!JsfUtils.isFlowRequest()) {
- delegate.processAction(actionEvent);
+ this.delegate.processAction(actionEvent);
return;
}
FacesContext context = FacesContext.getCurrentInstance();
- ActionSource source = (ActionSource) actionEvent.getSource();
+ ActionSource2 source = (ActionSource2) actionEvent.getSource();
String eventId = null;
- if (source.getAction() != null) {
+ if (source.getActionExpression() != null) {
if (logger.isDebugEnabled()) {
- logger.debug("Invoking action " + source.getAction());
+ logger.debug("Invoking action " + source.getActionExpression());
}
- eventId = (String) source.getAction().invoke(context, null);
+ eventId = (String) source.getActionExpression().invoke(context.getELContext(), null);
}
if (StringUtils.hasText(eventId)) {
if (logger.isDebugEnabled()) {
@@ -156,6 +152,6 @@ public class FlowActionListener implements ActionListener {
private void validate(RequestContext requestContext, Object model, String eventId) {
new ValidationHelper(model, requestContext, eventId, getModelExpression(requestContext).getExpressionString(),
- null, messageCodesResolver, null).validate();
+ null, this.messageCodesResolver, null).validate();
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplication.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplication.java
index 39157d5e..b2d768d6 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplication.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplication.java
@@ -15,93 +15,70 @@
*/
package org.springframework.faces.webflow;
-import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf20;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.el.ELContextListener;
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.el.ExpressionFactory;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
import javax.faces.application.Application;
-import javax.faces.application.NavigationHandler;
+import javax.faces.application.ApplicationWrapper;
import javax.faces.application.StateManager;
import javax.faces.application.ViewHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.PropertyResolver;
-import javax.faces.el.ReferenceSyntaxException;
-import javax.faces.el.ValueBinding;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.ActionListener;
-import javax.faces.validator.Validator;
import org.springframework.util.Assert;
/**
* Wraps an {@link Application} instance in order to ensure Web Flow specific implementations of {@link ViewHandler} and
- * {@link StateManager} are inserted at the front of the processing chain in JSF 1.2 and JSF 2.0 environments. This is
- * done by intercepting the corresponding setters. All other methods are simple delegation methods.
+ * {@link StateManager} are inserted at the front of the processing chain in JSF environments. This is done by
+ * intercepting the corresponding setters. All other methods are simple delegation methods.
*
* @author Rossen Stoyanchev
- *
- * @see Jsf2FlowApplication
+ * @author Phillip Webb
*/
-public class FlowApplication extends Application {
+public class FlowApplication extends ApplicationWrapper {
- private Application delegate;
+ private final Application wrapped;
/**
* Class constructor that accepts a delegate Application instance. If the delegate has default instantiation logic
- * for its StateManager and ViewHandler instances, those will be wrapped with {@link FlowViewStateManager} and a
+ * for its StateManager and ViewHandler instances, those will be wrapped with {@link FlowStateManager} and a
* {@link FlowViewHandler} instance.
*
- * @param delegate the Application instance to delegate to.
+ * @param wrapped the wrapped Application instance.
*/
- public FlowApplication(Application delegate) {
- Assert.notNull(delegate, "The delegate Application instance must not be null!");
- this.delegate = delegate;
+ public FlowApplication(Application wrapped) {
+ Assert.notNull(wrapped, "The wrapped Application instance must not be null!");
+ this.wrapped = wrapped;
- ViewHandler handler = this.delegate.getViewHandler();
+ ViewHandler handler = this.wrapped.getViewHandler();
if (shouldWrap(handler)) {
wrapAndSetViewHandler(handler);
}
- StateManager manager = this.delegate.getStateManager();
+ StateManager manager = this.wrapped.getStateManager();
if (shouldWrap(manager)) {
wrapAndSetStateManager(manager);
}
}
- /**
- * @return the wrapped Application instance
- */
- public Application getDelegate() {
- return delegate;
- }
-
- public ELContextListener[] getELContextListeners() {
- return getDelegate().getELContextListeners();
+ public Application getWrapped() {
+ return this.wrapped;
}
/**
- * Inserts {@link FlowViewStateManager} in front of the given StateManager (if not already done).
+ * Inserts {@link FlowStateManager} in front of the given StateManager (if not already done).
*/
public void setStateManager(StateManager manager) {
if (shouldWrap(manager)) {
wrapAndSetStateManager(manager);
} else {
- delegate.setStateManager(manager);
+ super.setStateManager(manager);
}
}
+ private boolean shouldWrap(StateManager manager) {
+ return (manager != null) && (!(manager instanceof FlowStateManager));
+ }
+
+ private void wrapAndSetStateManager(StateManager target) {
+ super.setStateManager(new FlowStateManager(target));
+ }
+
/**
* Inserts a {@link FlowViewHandler} in front of the given ViewHandler (if not already done).
*/
@@ -109,200 +86,20 @@ public class FlowApplication extends Application {
if (shouldWrap(handler)) {
wrapAndSetViewHandler(handler);
} else {
- delegate.setViewHandler(handler);
+ super.setViewHandler(handler);
}
}
- // ------------------- JSF 1.2 pass-through delegate methods ------------------//
-
- public void addComponent(String componentType, String componentClass) {
- delegate.addComponent(componentType, componentClass);
- }
-
- public void addConverter(String converterId, String converterClass) {
- delegate.addConverter(converterId, converterClass);
- }
-
- public void addConverter(Class> targetClass, String converterClass) {
- delegate.addConverter(targetClass, converterClass);
- }
-
- public void addELContextListener(ELContextListener listener) {
- getDelegate().addELContextListener(listener);
- }
-
- public void addELResolver(ELResolver resolver) {
- getDelegate().addELResolver(resolver);
- }
-
- public void addValidator(String validatorId, String validatorClass) {
- delegate.addValidator(validatorId, validatorClass);
- }
-
- public UIComponent createComponent(String componentType) throws FacesException {
- return delegate.createComponent(componentType);
- }
-
- public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType)
- throws FacesException {
- return delegate.createComponent(componentBinding, context, componentType);
- }
-
- public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType)
- throws FacesException {
- return getDelegate().createComponent(componentExpression, context, componentType);
- }
-
- public Converter createConverter(String converterId) {
- return delegate.createConverter(converterId);
- }
-
- public Converter createConverter(Class> targetClass) {
- return delegate.createConverter(targetClass);
- }
-
- public MethodBinding createMethodBinding(String ref, Class>... params) throws ReferenceSyntaxException {
- return delegate.createMethodBinding(ref, params);
- }
-
- public Validator createValidator(String validatorId) throws FacesException {
- return delegate.createValidator(validatorId);
- }
-
- public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException {
- return delegate.createValueBinding(ref);
- }
-
- public T evaluateExpressionGet(FacesContext context, String expression, Class extends T> expectedType)
- throws ELException {
- return getDelegate().evaluateExpressionGet(context, expression, expectedType);
- }
-
- public ActionListener getActionListener() {
- return delegate.getActionListener();
- }
-
- public Iterator getComponentTypes() {
- return delegate.getComponentTypes();
- }
-
- public Iterator getConverterIds() {
- return delegate.getConverterIds();
- }
-
- public Iterator> getConverterTypes() {
- return delegate.getConverterTypes();
- }
-
- public Locale getDefaultLocale() {
- return delegate.getDefaultLocale();
- }
-
- public String getDefaultRenderKitId() {
- return delegate.getDefaultRenderKitId();
- }
-
- public ELResolver getELResolver() {
- return getDelegate().getELResolver();
- }
-
- public ExpressionFactory getExpressionFactory() {
- return getDelegate().getExpressionFactory();
- }
-
- public String getMessageBundle() {
- return delegate.getMessageBundle();
- }
-
- public NavigationHandler getNavigationHandler() {
- return delegate.getNavigationHandler();
- }
-
- public PropertyResolver getPropertyResolver() {
- return delegate.getPropertyResolver();
- }
-
- public ResourceBundle getResourceBundle(FacesContext ctx, String name) {
- return getDelegate().getResourceBundle(ctx, name);
- }
-
- public StateManager getStateManager() {
- return delegate.getStateManager();
- }
-
- public Iterator getSupportedLocales() {
- return delegate.getSupportedLocales();
- }
-
- public Iterator getValidatorIds() {
- return delegate.getValidatorIds();
- }
-
- public VariableResolver getVariableResolver() {
- return delegate.getVariableResolver();
- }
-
- public ViewHandler getViewHandler() {
- return delegate.getViewHandler();
- }
-
- public void removeELContextListener(ELContextListener listener) {
- getDelegate().removeELContextListener(listener);
- }
-
- public void setActionListener(ActionListener listener) {
- delegate.setActionListener(listener);
- }
-
- public void setDefaultLocale(Locale locale) {
- delegate.setDefaultLocale(locale);
- }
-
- public void setDefaultRenderKitId(String renderKitId) {
- delegate.setDefaultRenderKitId(renderKitId);
- }
-
- public void setMessageBundle(String bundle) {
- delegate.setMessageBundle(bundle);
- }
-
- public void setNavigationHandler(NavigationHandler handler) {
- delegate.setNavigationHandler(handler);
- }
-
- public void setPropertyResolver(PropertyResolver resolver) {
- delegate.setPropertyResolver(resolver);
- }
-
- public void setSupportedLocales(Collection locales) {
- delegate.setSupportedLocales(locales);
- }
-
- public void setVariableResolver(VariableResolver resolver) {
- delegate.setVariableResolver(resolver);
- }
-
- // ------------------- Private helper methods ------------------//
-
private boolean shouldWrap(ViewHandler delegateViewHandler) {
return (delegateViewHandler != null) && (!(delegateViewHandler instanceof FlowViewHandler));
}
private boolean wrapAndSetViewHandler(ViewHandler target) {
if ((target != null) && (!(target instanceof FlowViewHandler))) {
- ViewHandler handler = (isAtLeastJsf20()) ? new Jsf2FlowViewHandler(target) : new FlowViewHandler(target);
- delegate.setViewHandler(handler);
+ ViewHandler handler = new FlowViewHandler(target);
+ super.setViewHandler(handler);
return true;
}
return false;
}
-
- private boolean shouldWrap(StateManager manager) {
- return (manager != null) && (!(manager instanceof FlowViewStateManager));
- }
-
- private void wrapAndSetStateManager(StateManager target) {
- delegate.setStateManager(new FlowViewStateManager(target));
- }
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplicationFactory.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplicationFactory.java
index a03db806..1ed14a05 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplicationFactory.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowApplicationFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
*/
package org.springframework.faces.webflow;
-import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf20;
-
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
@@ -29,32 +27,30 @@ import org.springframework.util.Assert;
* @see FlowApplication
*
* @author Jeremy Grelle
+ * @author Phillip Webb
*/
public class FlowApplicationFactory extends ApplicationFactory {
- private ApplicationFactory delegate;
+ private final ApplicationFactory wrapped;
- public FlowApplicationFactory(ApplicationFactory delegate) {
- Assert.notNull(delegate, "The delegate ApplicationFactory instance must not be null!");
- this.delegate = delegate;
+ public FlowApplicationFactory(ApplicationFactory wrapped) {
+ Assert.notNull(wrapped, "The wrapped ApplicationFactory instance must not be null!");
+ this.wrapped = wrapped;
}
public Application getApplication() {
- Application delegateApplication = delegate.getApplication();
- if (delegateApplication != null && (!(delegateApplication instanceof FlowApplication))) {
- Application flowApplication = (isAtLeastJsf20()) ? new Jsf2FlowApplication(delegateApplication)
- : new FlowApplication(delegateApplication);
- setApplication(flowApplication);
+ Application application = this.wrapped.getApplication();
+ if (application != null && (!(application instanceof FlowApplication))) {
+ setApplication(new FlowApplication(application));
}
- return delegate.getApplication();
+ return this.wrapped.getApplication();
}
public void setApplication(Application application) {
- delegate.setApplication(application);
+ this.wrapped.setApplication(application);
}
public ApplicationFactory getWrapped() {
- return delegate;
+ return this.wrapped;
}
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowELResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowELResolver.java
new file mode 100644
index 00000000..14a8063d
--- /dev/null
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowELResolver.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.faces.webflow;
+
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.access.el.SpringBeanELResolver;
+import org.springframework.beans.factory.support.StaticListableBeanFactory;
+import org.springframework.binding.expression.el.MapAdaptableELResolver;
+import org.springframework.webflow.execution.RequestContext;
+import org.springframework.webflow.execution.RequestContextHolder;
+import org.springframework.webflow.expression.el.FlowResourceELResolver;
+import org.springframework.webflow.expression.el.ImplicitFlowVariableELResolver;
+import org.springframework.webflow.expression.el.RequestContextELResolver;
+import org.springframework.webflow.expression.el.ScopeSearchingELResolver;
+
+/**
+ * Custom {@link ELResolver} for resolving web flow specific expressions.
+ *
+ * @author Jeremy Grelle
+ * @author Phillip Webb
+ *
+ * @since 2.4
+ */
+public class FlowELResolver extends CompositeELResolver {
+
+ public FlowELResolver() {
+ add(new RequestContextELResolver());
+ add(new ImplicitFlowVariableELResolver());
+ add(new FlowResourceELResolver());
+ add(new ScopeSearchingELResolver());
+ add(new MapAdaptableELResolver());
+ add(new BeanELResolver());
+ }
+
+ private static class BeanELResolver extends SpringBeanELResolver {
+
+ private static final BeanFactory EMPTY_BEAN_FACTORY = new StaticListableBeanFactory();
+
+ protected BeanFactory getBeanFactory(ELContext elContext) {
+ RequestContext requestContext = RequestContextHolder.getRequestContext();
+ if (requestContext == null) {
+ return EMPTY_BEAN_FACTORY;
+ }
+ BeanFactory beanFactory = requestContext.getActiveFlow().getApplicationContext();
+ return beanFactory != null ? beanFactory : EMPTY_BEAN_FACTORY;
+ }
+ }
+
+}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowExternalContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowExternalContext.java
new file mode 100644
index 00000000..ed7e40dc
--- /dev/null
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowExternalContext.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.faces.webflow;
+
+import java.io.IOException;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.ExternalContextWrapper;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.webflow.execution.RequestContext;
+
+/**
+ * Custom {@link ExternalContext} implementation that supports custom response objects other than
+ * {@link HttpServletResponse}.
+ *
+ * @author Jeremy Grelle
+ * @author Phillip Webb
+ * @author Rossen Stoyanchev
+ *
+ * @since 2.4
+ */
+public class FlowExternalContext extends ExternalContextWrapper {
+
+ Log logger = LogFactory.getLog(FlowExternalContext.class);
+
+ private static final String CUSTOM_RESPONSE = FlowExternalContext.class.getName() + ".customResponse";
+
+ private final ExternalContext wrapped;
+
+ private final RequestContext context;
+
+ public FlowExternalContext(RequestContext context, ExternalContext wrapped) {
+ this.context = context;
+ this.wrapped = wrapped;
+ }
+
+ public ExternalContext getWrapped() {
+ return this.wrapped;
+ }
+
+ public Object getResponse() {
+ if (this.context.getRequestScope().contains(CUSTOM_RESPONSE)) {
+ return this.context.getRequestScope().get(CUSTOM_RESPONSE);
+ }
+ return super.getResponse();
+ }
+
+ public void setResponse(Object response) {
+ this.context.getRequestScope().put(CUSTOM_RESPONSE, response);
+ super.setResponse(response);
+ }
+
+ public void responseSendError(int statusCode, String message) throws IOException {
+ this.logger.debug("Sending error HTTP status code " + statusCode + " with message '" + message + "'");
+ super.responseSendError(statusCode, message);
+ }
+
+}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java
index 12fccb4a..e25cc5e4 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java
@@ -15,28 +15,37 @@
*/
package org.springframework.faces.webflow;
-import java.lang.reflect.Method;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import javax.el.ELContext;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.faces.context.ResponseStream;
-import javax.faces.context.ResponseWriter;
+import javax.faces.context.FacesContextWrapper;
+import javax.faces.context.PartialViewContext;
+import javax.faces.context.PartialViewContextFactory;
import javax.faces.lifecycle.Lifecycle;
-import javax.faces.render.RenderKit;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
+import org.springframework.binding.message.Message;
+import org.springframework.binding.message.MessageCriteria;
+import org.springframework.binding.message.MessageResolver;
+import org.springframework.binding.message.Severity;
import org.springframework.context.MessageSource;
-import org.springframework.faces.webflow.context.portlet.PortletFacesContextImpl;
-import org.springframework.util.ClassUtils;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
import org.springframework.webflow.execution.RequestContext;
/**
@@ -45,82 +54,127 @@ import org.springframework.webflow.execution.RequestContext;
* {@code renderResponse} flag in flash scope so that the execution of the JSF {@link Lifecycle} may span multiple
* requests in the case of the POST+REDIRECT+GET pattern being enabled.
*
+ * @see FlowExternalContext
+ *
* @author Jeremy Grelle
* @author Phillip Webb
+ * @author Rossen Stoyanchev
*/
-public class FlowFacesContext extends FacesContext {
+public class FlowFacesContext extends FacesContextWrapper {
/**
* The key for storing the renderResponse flag
*/
static final String RENDER_RESPONSE_KEY = "flowRenderResponse";
- /**
- * The key for storing the renderResponse flag
- */
- private RequestContext context;
-
- private FlowFacesContextMessageDelegate messageDelegate;
-
- private ExternalContext externalContext;
-
- /**
- * The base FacesContext delegate
- */
- private FacesContext delegate;
-
- public static FlowFacesContext newInstance(RequestContext context, Lifecycle lifecycle) {
- FacesContext defaultFacesContext = null;
- if (JsfRuntimeInformation.isPortletRequest(context)) {
- defaultFacesContext = new PortletFacesContextImpl((PortletContext) context.getExternalContext()
- .getNativeContext(), (PortletRequest) context.getExternalContext().getNativeRequest(),
- (PortletResponse) context.getExternalContext().getNativeResponse());
- } else {
- FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- defaultFacesContext = facesContextFactory.getFacesContext(context.getExternalContext().getNativeContext(),
- context.getExternalContext().getNativeRequest(), context.getExternalContext().getNativeResponse(),
- lifecycle);
- }
- return (JsfRuntimeInformation.isAtLeastJsf20()) ? new Jsf2FlowFacesContext(context, defaultFacesContext)
- : new FlowFacesContext(context, defaultFacesContext);
+ private static final Map SPRING_SEVERITY_TO_FACES;
+ static {
+ SPRING_SEVERITY_TO_FACES = new HashMap();
+ SPRING_SEVERITY_TO_FACES.put(Severity.INFO, FacesMessage.SEVERITY_INFO);
+ SPRING_SEVERITY_TO_FACES.put(Severity.WARNING, FacesMessage.SEVERITY_WARN);
+ SPRING_SEVERITY_TO_FACES.put(Severity.ERROR, FacesMessage.SEVERITY_ERROR);
+ SPRING_SEVERITY_TO_FACES.put(Severity.FATAL, FacesMessage.SEVERITY_FATAL);
}
- public FlowFacesContext(RequestContext context, FacesContext delegate) {
+ private static final Map FACES_SEVERITY_TO_SPRING;
+ static {
+ FACES_SEVERITY_TO_SPRING = new HashMap();
+ for (Map.Entry entry : SPRING_SEVERITY_TO_FACES.entrySet()) {
+ FACES_SEVERITY_TO_SPRING.put(entry.getValue(), entry.getKey());
+ }
+ }
+
+ private final FacesContext wrapped;
+
+ private final RequestContext context;
+
+ private final ExternalContext externalContext;
+
+ private final PartialViewContext partialViewContext;
+
+ public FlowFacesContext(RequestContext context, FacesContext wrapped) {
this.context = context;
- this.delegate = delegate;
- this.messageDelegate = new FlowFacesContextMessageDelegate(context);
- this.externalContext = new FlowExternalContext(delegate.getExternalContext());
+ this.wrapped = wrapped;
+ this.externalContext = new FlowExternalContext(context, wrapped.getExternalContext());
+ PartialViewContextFactory factory = JsfUtils.findFactory(PartialViewContextFactory.class);
+ PartialViewContext partialViewContextDelegate = factory.getPartialViewContext(this);
+ this.partialViewContext = new FlowPartialViewContext(partialViewContextDelegate);
setCurrentInstance(this);
}
+ public FacesContext getWrapped() {
+ return this.wrapped;
+ }
+
+ public void release() {
+ super.release();
+ setCurrentInstance(null);
+ }
+
+ public ExternalContext getExternalContext() {
+ return this.externalContext;
+ }
+
+ public PartialViewContext getPartialViewContext() {
+ return this.partialViewContext;
+ }
+
+ public ELContext getELContext() {
+ ELContext elContext = super.getELContext();
+ // Ensure that our wrapper is used over the stock FacesContextImpl
+ elContext.putContext(FacesContext.class, this);
+ return elContext;
+ }
+
+ public boolean getRenderResponse() {
+ Boolean renderResponse = this.context.getFlashScope().getBoolean(RENDER_RESPONSE_KEY);
+ return (renderResponse == null ? false : renderResponse);
+ }
+
+ public boolean getResponseComplete() {
+ return this.context.getExternalContext().isResponseComplete();
+ }
+
+ public void renderResponse() {
+ // stored in flash scope to survive a redirect when transitioning from one view to another
+ this.context.getFlashScope().put(RENDER_RESPONSE_KEY, true);
+ }
+
+ public void responseComplete() {
+ this.context.getExternalContext().recordResponseComplete();
+ }
+
+ public boolean isValidationFailed() {
+ if (this.context.getMessageContext().hasErrorMessages()) {
+ return true;
+ } else {
+ return super.isValidationFailed();
+ }
+ }
+
/**
* Translates a FacesMessage to a Spring Web Flow message and adds it to the current MessageContext
*/
public void addMessage(String clientId, FacesMessage message) {
- messageDelegate.addToFlowMessageContext(clientId, message);
+ FacesMessageSource source = new FacesMessageSource(clientId);
+ FlowFacesMessage flowFacesMessage = new FlowFacesMessage(source, message);
+ this.context.getMessageContext().addMessage(flowFacesMessage);
}
/**
* Returns an Iterator for all component clientId's for which messages have been added.
*/
public Iterator getClientIdsWithMessages() {
- return messageDelegate.getClientIdsWithMessages();
- }
-
- public ELContext getELContext() {
- Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext");
- if (delegateMethod != null) {
- try {
- ELContext context = (ELContext) delegateMethod.invoke(delegate);
- context.putContext(FacesContext.class, this);
- return context;
- } catch (Exception e) {
- return null;
+ Set clientIds = new LinkedHashSet();
+ for (Message message : this.context.getMessageContext().getAllMessages()) {
+ Object source = message.getSource();
+ if (source != null && source instanceof String) {
+ clientIds.add((String) source);
+ } else if (message.getSource() instanceof FacesMessageSource) {
+ clientIds.add(((FacesMessageSource) source).getClientId());
}
- } else {
- return null;
}
+ return Collections.unmodifiableSet(clientIds).iterator();
}
/**
@@ -128,14 +182,36 @@ public class FlowFacesContext extends FacesContext {
* associated with any specific UIComponent. If no such messages have been queued, return null.
*/
public FacesMessage.Severity getMaximumSeverity() {
- return messageDelegate.getMaximumSeverity();
+ if (this.context.getMessageContext().getAllMessages().length == 0) {
+ return null;
+ }
+ FacesMessage.Severity max = FacesMessage.SEVERITY_INFO;
+ Iterator messages = getMessages();
+ while (messages.hasNext()) {
+ FacesMessage message = messages.next();
+ if (message.getSeverity().getOrdinal() > max.getOrdinal()) {
+ max = message.getSeverity();
+ }
+ if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal()) {
+ break;
+ }
+ }
+ return max;
}
/**
* Returns an Iterator for all Messages in the current MessageContext that does translation to FacesMessages.
*/
public Iterator getMessages() {
- return messageDelegate.getMessages();
+ return getMessageList().iterator();
+ }
+
+ /**
+ * Returns a List for all Messages in the current MessageContext that does translation to FacesMessages.
+ */
+ public List getMessageList() {
+ Message[] messages = this.context.getMessageContext().getAllMessages();
+ return asFacesMessages(messages);
}
/**
@@ -143,100 +219,189 @@ public class FlowFacesContext extends FacesContext {
* to FacesMessages.
*/
public Iterator getMessages(String clientId) {
- return messageDelegate.getMessages(clientId);
+ return getMessageList(clientId).iterator();
}
- public boolean getRenderResponse() {
- Boolean renderResponse = context.getFlashScope().getBoolean(RENDER_RESPONSE_KEY);
- return (renderResponse == null ? false : renderResponse);
- }
-
- public boolean getResponseComplete() {
- return context.getExternalContext().isResponseComplete();
- }
-
- public void renderResponse() {
- // stored in flash scope to survive a redirect when transitioning from one view to another
- context.getFlashScope().put(RENDER_RESPONSE_KEY, true);
- }
-
- public void responseComplete() {
- context.getExternalContext().recordResponseComplete();
- }
-
- // ------------------ Pass-through delegate methods ----------------------//
-
- public Application getApplication() {
- return delegate.getApplication();
- }
-
- public ExternalContext getExternalContext() {
- return externalContext;
- }
-
- public RenderKit getRenderKit() {
- return delegate.getRenderKit();
- }
-
- public ResponseStream getResponseStream() {
- return delegate.getResponseStream();
- }
-
- public ResponseWriter getResponseWriter() {
- return delegate.getResponseWriter();
- }
-
- public UIViewRoot getViewRoot() {
- return delegate.getViewRoot();
- }
-
- public void release() {
- delegate.release();
- setCurrentInstance(null);
- }
-
- public void setResponseStream(ResponseStream responseStream) {
- delegate.setResponseStream(responseStream);
- }
-
- public void setResponseWriter(ResponseWriter responseWriter) {
- delegate.setResponseWriter(responseWriter);
- }
-
- public void setViewRoot(UIViewRoot root) {
- delegate.setViewRoot(root);
- }
-
- protected FacesContext getDelegate() {
- return delegate;
- }
-
- protected FlowFacesContextMessageDelegate getMessageDelegate() {
- return messageDelegate;
- }
-
- protected class FlowExternalContext extends ExternalContextWrapper {
-
- private static final String CUSTOM_RESPONSE = "customResponse";
-
- public FlowExternalContext(ExternalContext delegate) {
- super(delegate);
- }
-
- public Object getResponse() {
- if (context.getRequestScope().contains(CUSTOM_RESPONSE)) {
- return context.getRequestScope().get(CUSTOM_RESPONSE);
+ /**
+ * Returns a List for all Messages with the given clientId in the current MessageContext that does translation to
+ * FacesMessages.
+ */
+ public List getMessageList(final String clientId) {
+ final FacesMessageSource source = new FacesMessageSource(clientId);
+ Message[] messages = this.context.getMessageContext().getMessagesByCriteria(new MessageCriteria() {
+ public boolean test(Message message) {
+ return ObjectUtils.nullSafeEquals(message.getSource(), source)
+ || ObjectUtils.nullSafeEquals(message.getSource(), clientId);
}
- return delegate.getResponse();
+ });
+ return asFacesMessages(messages);
+ }
+
+ private List asFacesMessages(Message[] messages) {
+ if (messages == null || messages.length == 0) {
+ return Collections.emptyList();
+ }
+ List facesMessages = new ArrayList();
+ for (Message message : messages) {
+ facesMessages.add(asFacesMessage(message));
+ }
+ return Collections.unmodifiableList(facesMessages);
+ }
+
+ private FacesMessage asFacesMessage(Message message) {
+ if (message instanceof FlowFacesMessage) {
+ return ((FlowFacesMessage) message).getFacesMessage();
+ }
+ FacesMessage.Severity severity = SPRING_SEVERITY_TO_FACES.get(message.getSeverity());
+ if (severity == null) {
+ severity = FacesMessage.SEVERITY_INFO;
+ }
+ return new FacesMessage(severity, message.getText(), null);
+ }
+
+ public static FlowFacesContext newInstance(RequestContext context, Lifecycle lifecycle) {
+ FacesContext defaultFacesContext = newDefaultInstance(context, lifecycle);
+ return new FlowFacesContext(context, defaultFacesContext);
+ }
+
+ private static FacesContext newDefaultInstance(RequestContext context, Lifecycle lifecycle) {
+ Object nativeContext = context.getExternalContext().getNativeContext();
+ Object nativeRequest = context.getExternalContext().getNativeRequest();
+ Object nativeResponse = context.getExternalContext().getNativeResponse();
+ return FacesContextHelper.newDefaultInstance(nativeContext, nativeRequest, nativeResponse, lifecycle);
+ }
+
+ /**
+ * Adapter class to convert a {@link FacesMessage} to a Spring {@link Message}. This adapter is required to allow
+ * FacesMessages to be registered with Spring whilst still retaining their mutable nature. It is not
+ * uncommon for FacesMessages to be changed after they have been added to a FacesContext, for
+ * example, from a PhaseListener.
+ *
+ * NOTE: Only {@link javax.faces.application.FacesMessage} instances are directly adapted, any subclasses will be
+ * converted to the standard FacesMessage implementation. This is to protect against bugs such as SWF-1073.
+ *
+ * For convenience this class also implements the {@link MessageResolver} interface.
+ */
+ protected static class FlowFacesMessage extends Message implements MessageResolver {
+
+ private transient FacesMessage facesMessage;
+
+ public FlowFacesMessage(FacesMessageSource source, FacesMessage message) {
+ super(source, null, null);
+ this.facesMessage = asStandardFacesMessageInstance(message);
}
/**
- * Store the native response object to be used for the duration of the Faces Request
+ * Use standard faces message as required to protect against bugs such as SWF-1073.
+ *
+ * @param message {@link javax.faces.application.FacesMessage} or subclass.
+ * @return {@link javax.faces.application.FacesMessage} instance
*/
- public void setResponse(Object response) {
- context.getRequestScope().put(CUSTOM_RESPONSE, response);
- delegate.setResponse(response);
+ private FacesMessage asStandardFacesMessageInstance(FacesMessage message) {
+ if (FacesMessage.class.equals(message.getClass())) {
+ return message;
+ }
+ return new FacesMessage(message.getSeverity(), message.getSummary(), message.getDetail());
}
+ // Custom serialization to work around myfaces bug MYFACES-1347
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeObject(this.facesMessage.getSummary());
+ oos.writeObject(this.facesMessage.getDetail());
+ oos.writeInt(this.facesMessage.getSeverity().getOrdinal());
+ }
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+ ois.defaultReadObject();
+ String summary = (String) ois.readObject();
+ String detail = (String) ois.readObject();
+ int severityOrdinal = ois.readInt();
+ FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO;
+ for (Iterator> iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
+ FacesMessage.Severity value = (FacesMessage.Severity) iterator.next();
+ if (value.getOrdinal() == severityOrdinal) {
+ severity = value;
+ }
+ }
+ this.facesMessage = new FacesMessage(severity, summary, detail);
+ }
+
+ public String getText() {
+ StringBuilder text = new StringBuilder();
+ if (StringUtils.hasLength(this.facesMessage.getSummary())) {
+ text.append(this.facesMessage.getSummary());
+ }
+ if (StringUtils.hasLength(this.facesMessage.getDetail())) {
+ text.append(text.length() == 0 ? "" : " : ");
+ text.append(this.facesMessage.getDetail());
+ }
+ return text.toString();
+ }
+
+ public Severity getSeverity() {
+ Severity severity = null;
+ if (this.facesMessage.getSeverity() != null) {
+ severity = FACES_SEVERITY_TO_SPRING.get(this.facesMessage.getSeverity());
+ }
+ return (severity == null ? Severity.INFO : severity);
+ }
+
+ public String toString() {
+ ToStringCreator rtn = new ToStringCreator(this);
+ rtn.append("severity", getSeverity());
+ if (FacesContext.getCurrentInstance() != null) {
+ // Only append text if running within a faces context
+ rtn.append("text", getText());
+ }
+ return rtn.toString();
+ }
+
+ public Message resolveMessage(MessageSource messageSource, Locale locale) {
+ return this;
+ }
+
+ /**
+ * @return The original {@link FacesMessage} adapted by this class.
+ */
+ public FacesMessage getFacesMessage() {
+ return this.facesMessage;
+ }
+ }
+
+ /**
+ * A Spring Message {@link Message#getSource() Source} that originated from JSF.
+ */
+ public static class FacesMessageSource implements Serializable {
+
+ private String clientId;
+
+ public FacesMessageSource(String clientId) {
+ if (StringUtils.hasLength(clientId)) {
+ this.clientId = clientId;
+ }
+ }
+
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ public int hashCode() {
+ return ObjectUtils.nullSafeHashCode(this.clientId);
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (obj.getClass().equals(FacesMessageSource.class)) {
+ return ObjectUtils.nullSafeEquals(getClientId(), ((FacesMessageSource) obj).getClientId());
+ }
+ return false;
+ }
}
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextLifecycleListener.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextLifecycleListener.java
index 8932832f..9b2b339f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextLifecycleListener.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextLifecycleListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,5 +44,4 @@ public class FlowFacesContextLifecycleListener extends FlowExecutionListenerAdap
public void requestProcessed(RequestContext context) {
FacesContext.getCurrentInstance().release();
}
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java
deleted file mode 100644
index 9e549830..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java
+++ /dev/null
@@ -1,412 +0,0 @@
-package org.springframework.faces.webflow;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-
-import org.springframework.binding.message.Message;
-import org.springframework.binding.message.MessageCriteria;
-import org.springframework.binding.message.MessageResolver;
-import org.springframework.binding.message.Severity;
-import org.springframework.context.MessageSource;
-import org.springframework.core.style.ToStringCreator;
-import org.springframework.util.StringUtils;
-import org.springframework.webflow.execution.RequestContext;
-
-/**
- * Helper delegate class for use with the {@link FlowFacesContext} that handles all faces message methods.
- *
- * @author Jeremy Grelle
- * @author Phillip Webb
- */
-public class FlowFacesContextMessageDelegate {
-
- private RequestContext context;
-
- /**
- * Key for identifying summary messages
- */
- static final String SUMMARY_MESSAGE_KEY = "_summary";
-
- /**
- * Key for identifying detail messages
- */
- static final String DETAIL_MESSAGE_KEY = "_detail";
-
- /**
- * Mappings between {@link FacesMessage} and {@link Severity}.
- */
- private static final Map FACESSEVERITY_TO_SPRINGSEVERITY;
- static {
- FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap();
- FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_INFO, Severity.INFO);
- FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_WARN, Severity.WARNING);
- FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_ERROR, Severity.ERROR);
- }
-
- public FlowFacesContextMessageDelegate(RequestContext context) {
- super();
- this.context = context;
- }
-
- /**
- * Whether Web Flow's MessageContext contains any errors.
- */
- public boolean hasErrorMessages() {
- return context.getMessageContext().hasErrorMessages();
- }
-
- /**
- * @see FlowFacesContext#addMessage(String, FacesMessage)
- */
- public void addToFlowMessageContext(String clientId, FacesMessage message) {
- String source = null;
- if (StringUtils.hasText(clientId)) {
- source = clientId;
- }
- context.getMessageContext().addMessage(new FlowFacesMessageAdapter(source, SUMMARY_MESSAGE_KEY, message));
- context.getMessageContext().addMessage(new FlowFacesMessageAdapter(source, DETAIL_MESSAGE_KEY, message));
- }
-
- /**
- * @see FlowFacesContext#getClientIdsWithMessages
- */
- public Iterator getClientIdsWithMessages() {
- return new ClientIdIterator();
- }
-
- /**
- * @see FlowFacesContext#getMaximumSeverity()
- */
- public FacesMessage.Severity getMaximumSeverity() {
- if (context.getMessageContext().getAllMessages().length == 0) {
- return null;
- }
- FacesMessage.Severity max = FacesMessage.SEVERITY_INFO;
- Iterator messages = getMessages();
- while (messages.hasNext()) {
- FacesMessage message = messages.next();
- if (message.getSeverity().getOrdinal() > max.getOrdinal()) {
- max = message.getSeverity();
- }
- if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal()) {
- break;
- }
- }
- return max;
- }
-
- /**
- * @see FlowFacesContext#getMessages()
- */
- public Iterator getMessages() {
- return new FacesMessageIterator();
- }
-
- /**
- * @see FlowFacesContext#getMessages(String)
- */
- public Iterator getMessages(String clientId) {
- return new FacesMessageIterator(clientId);
- }
-
- /**
- * @see Jsf2FlowFacesContext#getMessageList()
- */
- public List getMessageList() {
- return new FacesMessageIterator().asList();
- }
-
- /**
- * @see Jsf2FlowFacesContext#getMessageList(String)
- */
- public List getMessageList(String clientId) {
- return new FacesMessageIterator(clientId).asList();
- }
-
- // ------------------ Private helper methods ----------------------//
-
- private FacesMessage toFacesMessage(Message summaryMessage, Message detailMessage) {
-
- // If we can return the actual message instance.
- if (summaryMessage instanceof FlowFacesMessageAdapter) {
- return ((FlowFacesMessageAdapter) summaryMessage).getFacesMessage();
- }
- if (detailMessage instanceof FlowFacesMessageAdapter) {
- return ((FlowFacesMessageAdapter) detailMessage).getFacesMessage();
- }
-
- // If we have not got an actual instance adapt the message
- if (summaryMessage.getSeverity() == Severity.INFO) {
- return new FacesMessage(FacesMessage.SEVERITY_INFO, summaryMessage.getText(), detailMessage.getText());
- } else if (summaryMessage.getSeverity() == Severity.WARNING) {
- return new FacesMessage(FacesMessage.SEVERITY_WARN, summaryMessage.getText(), detailMessage.getText());
- } else if (summaryMessage.getSeverity() == Severity.ERROR) {
- return new FacesMessage(FacesMessage.SEVERITY_ERROR, summaryMessage.getText(), detailMessage.getText());
- } else {
- return new FacesMessage(FacesMessage.SEVERITY_FATAL, summaryMessage.getText(), detailMessage.getText());
- }
- }
-
- private class FacesMessageIterator implements Iterator {
-
- private List messages;
-
- private int currentIndex = -1;
-
- protected FacesMessageIterator() {
- Message[] summaryMessages = context.getMessageContext().getMessagesByCriteria(new SummaryMessageCriteria());
- Message[] detailMessages = context.getMessageContext().getMessagesByCriteria(new DetailMessageCriteria());
- Message[] userMessages = context.getMessageContext().getMessagesByCriteria(new UserMessageCriteria());
-
- messages = new ArrayList();
- for (int i = 0; i < summaryMessages.length; i++) {
- messages.add(toFacesMessage(summaryMessages[i], detailMessages[i]));
- }
- for (Message userMessage : userMessages) {
- messages.add(toFacesMessage(userMessage, userMessage));
- }
- }
-
- protected FacesMessageIterator(String clientId) {
- Message[] summaryMessages = context.getMessageContext().getMessagesBySource(clientId + SUMMARY_MESSAGE_KEY);
- Message[] detailMessages = context.getMessageContext().getMessagesBySource(clientId + DETAIL_MESSAGE_KEY);
- Message[] userMessages = context.getMessageContext().getMessagesBySource(clientId);
-
- this.messages = new ArrayList();
- for (int i = 0; i < summaryMessages.length; i++) {
- messages.add(toFacesMessage(summaryMessages[i], detailMessages[i]));
- }
- for (Message userMessage : userMessages) {
- messages.add(toFacesMessage(userMessage, userMessage));
- }
- }
-
- public boolean hasNext() {
- return messages.size() > currentIndex + 1;
- }
-
- public FacesMessage next() {
- currentIndex++;
- return messages.get(currentIndex);
- }
-
- public void remove() {
- throw new UnsupportedOperationException("Messages cannot be removed through this iterator.");
- }
-
- public List asList() {
- if (null == messages) {
- return Collections.unmodifiableList(Collections. emptyList());
- } else {
- return Collections.unmodifiableList(messages);
- }
- }
-
- }
-
- private class ClientIdIterator implements Iterator {
-
- private Message[] messages;
-
- int currentIndex = -1;
-
- protected ClientIdIterator() {
- this.messages = context.getMessageContext().getMessagesByCriteria(new IdentifiedMessageCriteria());
- }
-
- public boolean hasNext() {
- return messages.length > currentIndex + 1;
- }
-
- public String next() {
- Message next = messages[++currentIndex];
- if (next.getSource() == null) {
- return null;
- } else if (next.getSource().toString().endsWith(SUMMARY_MESSAGE_KEY)) {
- return next.getSource().toString().replaceAll(SUMMARY_MESSAGE_KEY, "");
- } else {
- return next.getSource().toString();
- }
- }
-
- public void remove() {
- throw new UnsupportedOperationException("Messages cannot be removed through this iterator.");
- }
-
- }
-
- private class SummaryMessageCriteria implements MessageCriteria {
-
- public boolean test(Message message) {
- if (message.getSource() == null) {
- return false;
- }
- return message.getSource().toString().endsWith(SUMMARY_MESSAGE_KEY);
- }
- }
-
- private class DetailMessageCriteria implements MessageCriteria {
-
- public boolean test(Message message) {
- if (message.getSource() == null) {
- return false;
- }
- return message.getSource().toString().endsWith(DETAIL_MESSAGE_KEY);
- }
- }
-
- private class UserMessageCriteria implements MessageCriteria {
-
- public boolean test(Message message) {
- if (message.getSource() == null) {
- return true;
- }
- return !message.getSource().toString().endsWith(SUMMARY_MESSAGE_KEY)
- && !message.getSource().toString().endsWith(DETAIL_MESSAGE_KEY);
- }
- }
-
- private class IdentifiedMessageCriteria implements MessageCriteria {
-
- String nullSummaryId = null + SUMMARY_MESSAGE_KEY;
-
- private Set identifiedMessageSources = new HashSet();
-
- // From getClientIdsWithMessages docs: If any messages have been queued that were not associated with
- // any specific client identifier, a null value will be included in the iterated values.
- public boolean test(Message message) {
- if (message.getSource() != null && message.getSource().toString().endsWith(DETAIL_MESSAGE_KEY)) {
- return false;
- } else if (message.getSource() == null || message.getSource().equals("")
- || message.getSource().equals(nullSummaryId)) {
- return identifiedMessageSources.add(null);
- }
- return identifiedMessageSources.add((String) message.getSource());
- }
- }
-
- /**
- * Adapter class to convert a {@link FacesMessage} to a Spring {@link Message}. This adapter is required to allow
- * FacesMessages to be registered with spring while still retaining their mutable nature. It is not
- * uncommon for FacesMessages to be changed after they have been added to a FacesContext, for
- * example, from a PhaseListener.
- *
- * NOTE: Only {@link javax.faces.application.FacesMessage} instances are directly adapted, any subclasses will be
- * converted to the standard FacesMessage implementation. This is to protect against bugs such as SWF-1073.
- *
- * For convenience this class also implements the {@link MessageResolver} interface.
- */
- private static class FlowFacesMessageAdapter extends Message implements MessageResolver {
-
- private String key;
- private String source;
- private transient FacesMessage facesMessage;
-
- public FlowFacesMessageAdapter(String source, String key, FacesMessage message) {
- super(null, null, null);
- this.source = source;
- this.key = key;
- this.facesMessage = asStandardFacesMessageInstance(message);
- }
-
- // Custom serialization to work around myfaces bug MYFACES-1347
-
- private void writeObject(ObjectOutputStream oos) throws IOException {
- oos.defaultWriteObject();
- oos.writeObject(facesMessage.getSummary());
- oos.writeObject(facesMessage.getDetail());
- oos.writeInt(facesMessage.getSeverity().getOrdinal());
- }
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- String summary = (String) ois.readObject();
- String detail = (String) ois.readObject();
- int severityOrdinal = ois.readInt();
- FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO;
- for (Iterator> iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
- FacesMessage.Severity value = (FacesMessage.Severity) iterator.next();
- if (value.getOrdinal() == severityOrdinal) {
- severity = value;
- }
- }
- facesMessage = new FacesMessage(severity, summary, detail);
- }
-
- /**
- * Use standard faces message as required to protect against bugs such as SWF-1073.
- *
- * @param message {@link javax.faces.application.FacesMessage} or subclass.
- * @return {@link javax.faces.application.FacesMessage} instance
- */
- private FacesMessage asStandardFacesMessageInstance(FacesMessage message) {
- if (FacesMessage.class.equals(message.getClass())) {
- return message;
- }
- return new FacesMessage(message.getSeverity(), message.getSummary(), message.getDetail());
- }
-
- public Object getSource() {
- return source + key;
- }
-
- public String getText() {
- String text = null;
- if (DETAIL_MESSAGE_KEY.equals(key)) {
- text = facesMessage.getDetail();
- } else if (SUMMARY_MESSAGE_KEY.equals(key)) {
- text = facesMessage.getSummary();
- } else {
- throw new RuntimeException("Unknown faces message type key");
- }
-
- if (StringUtils.hasText(text)) {
- return text;
- }
- return "";
- }
-
- public Severity getSeverity() {
- Severity severity = null;
- if (facesMessage.getSeverity() != null) {
- severity = FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity());
- }
- return (severity == null ? Severity.INFO : severity);
- }
-
- public String toString() {
- ToStringCreator rtn = new ToStringCreator(this);
- rtn.append("severity", getSeverity());
- if (FacesContext.getCurrentInstance() != null) {
- // Only append text if running within a faces context
- rtn.append("text", getText());
- }
- return rtn.toString();
- }
-
- public Message resolveMessage(MessageSource messageSource, Locale locale) {
- return this;
- }
-
- /**
- * @return The original {@link FacesMessage} adapted by this class.
- */
- public FacesMessage getFacesMessage() {
- return facesMessage;
- }
-
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java
index e8c411c8..019d26a9 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java
@@ -15,18 +15,15 @@
*/
package org.springframework.faces.webflow;
-import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf20;
-
import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.lifecycle.LifecycleFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.faces.support.LifecycleWrapper;
/**
* Custom {@link Lifecycle} for Spring Web Flow that only executes the APPLY_REQUEST_VALUES through INVOKE_APPLICATION
@@ -37,23 +34,27 @@ import org.apache.commons.logging.LogFactory;
*
*
* @author Jeremy Grelle
+ * @author Phillip Webb
*/
-public class FlowLifecycle extends Lifecycle {
+public class FlowLifecycle extends LifecycleWrapper {
private static final Log logger = LogFactory.getLog(FlowLifecycle.class);
- private final Lifecycle delegate;
+ private final Lifecycle wrapped;
public static Lifecycle newInstance() {
- LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
- .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ LifecycleFactory lifecycleFactory = JsfUtils.findFactory(LifecycleFactory.class);
Lifecycle defaultLifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
return new FlowLifecycle(defaultLifecycle);
}
- FlowLifecycle(Lifecycle delegate) {
- this.delegate = delegate;
+ FlowLifecycle(Lifecycle wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public Lifecycle getWrapped() {
+ return this.wrapped;
}
/**
@@ -64,43 +65,12 @@ public class FlowLifecycle extends Lifecycle {
for (int p = PhaseId.APPLY_REQUEST_VALUES.getOrdinal(); p <= PhaseId.INVOKE_APPLICATION.getOrdinal(); p++) {
PhaseId phaseId = PhaseId.VALUES.get(p);
if (!skipPhase(context, phaseId)) {
- if (isAtLeastJsf20()) {
- context.setCurrentPhaseId(phaseId);
- }
+ context.setCurrentPhaseId(phaseId);
invokePhase(context, phaseId);
}
}
}
- /**
- * Delegates to the wrapped {@link Lifecycle}.
- * @throws FacesException
- */
- public void render(FacesContext context) throws FacesException {
- delegate.render(context);
- }
-
- /**
- * Delegates to the wrapped {@link Lifecycle}.
- */
- public void addPhaseListener(PhaseListener listener) {
- delegate.addPhaseListener(listener);
- }
-
- /**
- * Delegates to the wrapped {@link Lifecycle}.
- */
- public PhaseListener[] getPhaseListeners() {
- return delegate.getPhaseListeners();
- }
-
- /**
- * Delegates to the wrapped {@link Lifecycle}.
- */
- public void removePhaseListener(PhaseListener listener) {
- delegate.removePhaseListener(listener);
- }
-
private boolean skipPhase(FacesContext context, PhaseId phaseId) {
if (context.getResponseComplete()) {
return true;
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java
index bc0ff70e..f84a39a9 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java
@@ -27,22 +27,22 @@ import org.springframework.webflow.execution.RequestContextHolder;
import org.springframework.webflow.execution.View;
/**
- * Web Flow {@link PartialViewContext} implementation allowing ids for partial rendering to be specified from the
+ * Web Flow {@link PartialViewContext} implementation allowing IDs for partial rendering to be specified from the
* server-side. This is done in a flow definition with the <render fragments="..." /> action.
*
* @author Rossen Stoyanchev
*/
public class FlowPartialViewContext extends PartialViewContextWrapper {
- private PartialViewContext delegate;
+ private final PartialViewContext wrapped;
- public FlowPartialViewContext(PartialViewContext delegate) {
- this.delegate = delegate;
+ public FlowPartialViewContext(PartialViewContext wrapped) {
+ this.wrapped = wrapped;
}
@Override
public PartialViewContext getWrapped() {
- return delegate;
+ return this.wrapped;
}
@Override
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPropertyResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPropertyResolver.java
deleted file mode 100644
index b7bd93ba..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPropertyResolver.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2004-2008 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import javax.el.CompositeELResolver;
-import javax.faces.el.PropertyResolver;
-
-import org.springframework.binding.collection.MapAdaptable;
-import org.springframework.binding.expression.el.MapAdaptableELResolver;
-import org.springframework.context.MessageSource;
-import org.springframework.faces.expression.ELDelegatingPropertyResolver;
-import org.springframework.webflow.expression.el.FlowResourceELResolver;
-
-/**
- * Custom property resolver for resolving properties on web flow specific structures with JSF 1.1 or > by delegating to
- * web flow's EL resolvers.
- *
- *
- * This resolver handles resolving properties on a {@link MapAdaptable} collection and a flow-local
- * {@link MessageSource}
- *
- * @author Jeremy Grelle
- */
-public class FlowPropertyResolver extends ELDelegatingPropertyResolver {
-
- private static final CompositeELResolver composite = new CompositeELResolver();
-
- static {
- composite.add(new FlowResourceELResolver());
- composite.add(new MapAdaptableELResolver());
- }
-
- public FlowPropertyResolver(PropertyResolver nextResolver) {
- super(nextResolver, composite);
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowRenderKit.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowRenderKit.java
index f2d2070e..ad8fb52f 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowRenderKit.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowRenderKit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,43 +17,62 @@ package org.springframework.faces.webflow;
/**
* A render kit implementation that ensures use of Web Flow's FlowViewResponseStateManager, which takes over reading and
- * writing JSF state and manages that in Web Flow's view scope. The FlowViewResponseStateManager is plugged in only in a
- * JSF 2 environment.
- *
- * Note that partial state saving in Apache MyFaces is not yet supported. Use the javax.faces.PARTIAL_STATE_SAVING context
- * parameter in web.xml to disable it.
- *
+ * writing JSF state and manages that in Web Flow's view scope.
+ *
* @author Rossen Stoyanchev
+ * @author Phillip Webb
* @since 2.2.0
*/
+import java.lang.reflect.Constructor;
+
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitWrapper;
import javax.faces.render.ResponseStateManager;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.util.ClassUtils;
+
public class FlowRenderKit extends RenderKitWrapper {
- private RenderKit delegate;
+ private final RenderKit wrapped;
- private FlowViewResponseStateManager responseStateManager;
+ private final ResponseStateManager flowViewResponseStateManager;
- public FlowRenderKit(RenderKit delegate) {
- this.delegate = delegate;
- if (JsfRuntimeInformation.isAtLeastJsf20()) {
- this.responseStateManager = new FlowViewResponseStateManager(delegate.getResponseStateManager());
+ public FlowRenderKit(RenderKit wrapped) {
+ this.wrapped = wrapped;
+ this.flowViewResponseStateManager = initResponseStateManager(wrapped.getResponseStateManager());
+ }
+
+ private ResponseStateManager initResponseStateManager(ResponseStateManager wrapped) {
+ if (!JsfRuntimeInformation.isMyFacesPresent()) {
+ return new FlowResponseStateManager(wrapped);
}
+ Constructor> constructor;
+ try {
+ String className = "org.springframework.faces.webflow.MyFacesFlowResponseStateManager";
+ Class> clazz = ClassUtils.forName(className, FlowRenderKit.class.getClassLoader());
+ constructor = ClassUtils.getConstructorIfAvailable(clazz, FlowResponseStateManager.class);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException("Could not initialize MyFacesFlowResponseStateManager", e);
+ } catch (LinkageError e) {
+ throw new IllegalStateException("Could not initialize MyFacesFlowResponseStateManager", e);
+ }
+ return (ResponseStateManager) BeanUtils.instantiateClass(constructor, new FlowResponseStateManager(wrapped));
}
public RenderKit getWrapped() {
- return delegate;
+ return this.wrapped;
}
/**
- * Returns an instance of {@link FlowViewResponseStateManager} in a JSF 2 environment or returns the delegates's
+ * Returns an instance of {@link FlowResponseStateManager} in a JSF 2 environment or returns the delegates's
* ResponseStateManager instance otherwise.
*/
public ResponseStateManager getResponseStateManager() {
- return (JsfUtils.isFlowRequest() && JsfRuntimeInformation.isPartialStateSavingSupported()) ? responseStateManager
- : delegate.getResponseStateManager();
+ if (JsfUtils.isFlowRequest()) {
+ return this.flowViewResponseStateManager;
+ }
+ return this.wrapped.getResponseStateManager();
}
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResourceResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResourceResolver.java
index dada8743..9df44b0d 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResourceResolver.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResourceResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,17 +17,19 @@ package org.springframework.faces.webflow;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import javax.faces.FacesException;
+import javax.faces.view.facelets.ResourceResolver;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;
+import org.springframework.util.ClassUtils;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.RequestContextHolder;
-import com.sun.facelets.impl.DefaultResourceResolver;
-import com.sun.facelets.impl.ResourceResolver;
-
/**
* Resolves Facelets templates using Spring Resource paths such as "classpath:foo.xhtml". Configure it via a context
* parameter in web.xml:
@@ -41,14 +43,42 @@ import com.sun.facelets.impl.ResourceResolver;
*
* @see Jsf2FlowResourceResolver
*/
-public class FlowResourceResolver implements ResourceResolver {
+public class FlowResourceResolver extends ResourceResolver {
- ResourceResolver delegateResolver = new DefaultResourceResolver();
+ /**
+ * All known {@link ResourceResolver} implementations in the priority order
+ */
+ private static final List RESOLVERS_CLASSES;
+ static {
+ List resolvers = new ArrayList();
+ resolvers.add("com.sun.faces.facelets.impl.DefaultResourceResolver");
+ resolvers.add("org.apache.myfaces.view.facelets.impl.DefaultResourceResolver");
+ RESOLVERS_CLASSES = Collections.unmodifiableList(resolvers);
+ }
+
+ private final ResourceResolver delegateResolver;
+
+ public FlowResourceResolver() {
+ this.delegateResolver = createDelegateResolver();
+ }
+
+ private ResourceResolver createDelegateResolver() {
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ for (String resolverClass : RESOLVERS_CLASSES) {
+ if (ClassUtils.isPresent(resolverClass, classLoader)) {
+ return (ResourceResolver) ClassUtils.forName(resolverClass, classLoader).newInstance();
+ }
+ }
+ } catch (Exception e) {
+ }
+ throw new IllegalStateException("Unable to find Default ResourceResolver");
+ }
public URL resolveUrl(String path) {
if (!JsfUtils.isFlowRequest()) {
- return delegateResolver.resolveUrl(path);
+ return this.delegateResolver.resolveUrl(path);
}
try {
@@ -63,7 +93,7 @@ public class FlowResourceResolver implements ResourceResolver {
if (viewResource.exists()) {
return viewResource.getURL();
} else {
- return delegateResolver.resolveUrl(path);
+ return this.delegateResolver.resolveUrl(path);
}
} catch (IOException ex) {
throw new FacesException(ex);
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewResponseStateManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java
similarity index 55%
rename from spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewResponseStateManager.java
rename to spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java
index 69e6c8c6..18caa645 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewResponseStateManager.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2010 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.faces.webflow;
import java.io.IOException;
import java.io.Writer;
-import javax.faces.application.StateManager.SerializedView;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.RenderKitFactory;
@@ -26,90 +25,62 @@ import javax.faces.render.ResponseStateManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.faces.support.ResponseStateManagerWrapper;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.RequestContextHolder;
/**
- *
* A custom ResponseStateManager that writes JSF state to a Web Flow managed view-scoped variable. This class is plugged
- * in via {@link FlowRenderKit} in JSF 2 runtime environments only.
- *
- *
- *
- * In JSF 2 where a partial state saving algorithm is used, Web Flow delegates to the JSF 2 runtime to handle state
- * saving. However, an instance of this class plugged in via {@link FlowRenderKit} will ensure that state is saved in a
- * Web Flow managed view-scoped variable.
- *
+ * in via {@link FlowRenderKit}.
*
* @author Rossen Stoyanchev
+ * @author Phillip Webb
+ *
* @since 2.2.0
*/
-public class FlowViewResponseStateManager extends ResponseStateManager {
+public class FlowResponseStateManager extends ResponseStateManagerWrapper {
- private static final Log logger = LogFactory.getLog(FlowViewResponseStateManager.class);
+ private static final Log logger = LogFactory.getLog(FlowResponseStateManager.class);
- private ResponseStateManager delegate;
+ static final String FACES_VIEW_STATE = "facesViewState";
- private char[] stateFieldStart = ("".toCharArray();
+ private static final char[] STATE_FIELD_END = "\" />".toCharArray();
- public FlowViewResponseStateManager(ResponseStateManager delegate) {
- this.delegate = delegate;
+ private final ResponseStateManager wrapped;
+
+ public FlowResponseStateManager(ResponseStateManager wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public ResponseStateManager getWrapped() {
+ return this.wrapped;
}
- /**
- *
- * Wraps state in an instance of {@link FlowSerializedView} and stores it in view scope.
- *
- *
- *
- * Also complies with the contract for {@link ResponseStateManager#writeState(FacesContext, Object)} by writing the
- * "javax.faces.ViewState" and optionally the "javax.faces.RenderKitId" hidden input fields to the response.
- *
- * Retrieves the state from view scope as an instance of {@link FlowSerializedView} and turns it to an array before
- * returning.
- *
- */
@Override
public Object getState(FacesContext facesContext, String viewId) {
if (!JsfUtils.isFlowRequest()) {
- return delegate.getState(facesContext, viewId);
+ return super.getState(facesContext, viewId);
}
RequestContext requestContext = RequestContextHolder.getRequestContext();
- FlowSerializedView view = (FlowSerializedView) requestContext.getViewScope().get(
- FlowViewStateManager.SERIALIZED_VIEW_STATE);
- Object[] state = null;
- if (view == null) {
+ Object state = requestContext.getViewScope().get(FACES_VIEW_STATE);
+ if (state == null) {
logger.debug("No matching view in view scope");
- } else {
- state = new Object[] { view.getTreeStructure(), view.getComponentState() };
}
return state;
}
@@ -123,35 +94,17 @@ public class FlowViewResponseStateManager extends ResponseStateManager {
@Override
public String getViewState(FacesContext facesContext, Object state) {
if (!JsfUtils.isFlowRequest()) {
- return delegate.getViewState(facesContext, state);
+ return super.getViewState(facesContext, state);
}
+ saveState(state);
return getFlowExecutionKey();
}
- // ------------------- Delegation methods ------------------//
-
- @Override
- public boolean isPostback(FacesContext context) {
- return delegate.isPostback(context);
+ private void saveState(Object state) {
+ RequestContext requestContext = RequestContextHolder.getRequestContext();
+ requestContext.getViewScope().put(FACES_VIEW_STATE, state);
}
- @Override
- public Object getTreeStructureToRestore(FacesContext context, String viewId) {
- return delegate.getTreeStructureToRestore(context, viewId);
- }
-
- @Override
- public Object getComponentStateToRestore(FacesContext context) {
- return delegate.getComponentStateToRestore(context);
- }
-
- @Override
- public void writeState(FacesContext context, SerializedView state) throws IOException {
- delegate.writeState(context, state);
- }
-
- // ------------------- Private helper methods ------------------//
-
private String getFlowExecutionKey() {
RequestContext requestContext = RequestContextHolder.getRequestContext();
return requestContext.getFlowExecutionContext().getKey().toString();
@@ -165,9 +118,9 @@ public class FlowViewResponseStateManager extends ResponseStateManager {
* @throws IOException if an error occurs writing to the client
*/
private void writeViewStateField(FacesContext context, Writer writer) throws IOException {
- writer.write(stateFieldStart);
+ writer.write(STATE_FIELD_START);
writer.write(getFlowExecutionKey());
- writer.write(stateFieldEnd);
+ writer.write(STATE_FIELD_END);
}
/**
@@ -188,5 +141,4 @@ public class FlowViewResponseStateManager extends ResponseStateManager {
writer.endElement("input");
}
}
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowSerializedView.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowSerializedView.java
deleted file mode 100644
index 5aa54393..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowSerializedView.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.springframework.faces.webflow;
-
-import java.io.Serializable;
-
-import org.springframework.core.style.ToStringCreator;
-
-/**
- * Serialized UIViewRoot stored in view scope associated with a Web Flow View State.
- *
- * @author Jeremy Grelle
- */
-public class FlowSerializedView implements Serializable {
-
- private Object treeStructure;
-
- private Object componentState;
-
- private String viewId;
-
- /**
- * Creates a new serialized view
- * @param viewId the view id
- * @param treeStructure the tree structure of the view
- * @param componentState the component state
- */
- public FlowSerializedView(String viewId, Object treeStructure, Object componentState) {
- this.viewId = viewId;
- this.treeStructure = treeStructure;
- this.componentState = componentState;
- }
-
- public String getViewId() {
- return this.viewId;
- }
-
- public Object getTreeStructure() {
- return this.treeStructure;
- }
-
- public Object getComponentState() {
- return this.componentState;
- }
-
- public Object[] asTreeStructAndCompStateArray() {
- return new Object[] { this.treeStructure, this.componentState };
- }
-
- public String toString() {
- return new ToStringCreator(this).append("viewId", viewId).toString();
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowStateManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowStateManager.java
new file mode 100644
index 00000000..3d5a8971
--- /dev/null
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowStateManager.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.faces.webflow;
+
+import javax.faces.application.StateManager;
+import javax.faces.application.StateManagerWrapper;
+import javax.faces.context.FacesContext;
+
+/**
+ * Custom {@link StateManager} that manages ensures web flow's state is always stored server side.
+ *
+ * @author Jeremy Grelle
+ * @author Rossen Stoyanchev
+ * @author Phillip Webb
+ *
+ * @since 2.4
+ */
+public class FlowStateManager extends StateManagerWrapper {
+
+ private final StateManager wrapped;
+
+ public FlowStateManager(StateManager wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public StateManager getWrapped() {
+ return this.wrapped;
+ }
+
+ public boolean isSavingStateInClient(FacesContext context) {
+ if (!JsfUtils.isFlowRequest()) {
+ return super.isSavingStateInClient(context);
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java
deleted file mode 100644
index 39a92e64..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2004-2008 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import javax.el.CompositeELResolver;
-import javax.faces.el.VariableResolver;
-
-import org.springframework.faces.expression.ELDelegatingVariableResolver;
-import org.springframework.webflow.expression.el.FlowResourceELResolver;
-import org.springframework.webflow.expression.el.ImplicitFlowVariableELResolver;
-import org.springframework.webflow.expression.el.RequestContextELResolver;
-import org.springframework.webflow.expression.el.ScopeSearchingELResolver;
-
-/**
- * Custom variabe resolver for resolving properties on web flow specific variables with JSF 1.1 or > by delegating to
- * web flow's EL resolvers.
- *
- * @author Jeremy Grelle
- */
-public class FlowVariableResolver extends ELDelegatingVariableResolver {
-
- private static final CompositeELResolver composite = new CompositeELResolver();
-
- static {
- composite.add(new RequestContextELResolver());
- composite.add(new ImplicitFlowVariableELResolver());
- composite.add(new FlowResourceELResolver());
- composite.add(new ScopeSearchingELResolver());
- }
-
- public FlowVariableResolver(VariableResolver nextResolver) {
- super(nextResolver, composite);
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewHandler.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewHandler.java
index 8cbbff81..4dd272b5 100644
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewHandler.java
+++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 the original author or authors.
+ * Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.springframework.faces.webflow;
-import java.io.IOException;
import java.util.Locale;
-import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
+import javax.faces.application.ViewHandlerWrapper;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
@@ -32,31 +31,31 @@ import org.springframework.webflow.execution.RequestContextHolder;
import org.springframework.webflow.execution.View;
/**
- * Simple delegating {@link ViewHandler} implementation that provides JSF Form's with the correct FlowExecution URL,
- * including the current FlowExecutionKey, so that postbacks may be properly intercepted and handled by Web Flow.
+ * Simple {@link ViewHandler} implementation that provides JSF Form's with the correct FlowExecution URL, including the
+ * current FlowExecutionKey, so that postbacks may be properly intercepted and handled by Web Flow.
*
* @author Jeremy Grelle
- *
- * @see Jsf2FlowViewHandler
+ * @author Rossen Stoyanchev
+ * @author Phillip Webb
*/
-public class FlowViewHandler extends ViewHandler {
+public class FlowViewHandler extends ViewHandlerWrapper {
- private ViewHandler delegate;
+ private final ViewHandler wrapped;
- public FlowViewHandler(ViewHandler delegate) {
- Assert.notNull(delegate, "The delegate ViewHandler instance must not be null!");
- this.delegate = delegate;
+ public FlowViewHandler(ViewHandler wrapped) {
+ Assert.notNull(wrapped, "The wrapped ViewHandler instance must not be null!");
+ this.wrapped = wrapped;
}
- protected ViewHandler getDelegate() {
- return delegate;
+ public ViewHandler getWrapped() {
+ return this.wrapped;
}
public String getActionURL(FacesContext context, String viewId) {
if (JsfUtils.isFlowRequest()) {
return RequestContextHolder.getRequestContext().getFlowExecutionUrl();
} else {
- return delegate.getActionURL(context, viewId);
+ return super.getActionURL(context, viewId);
}
}
@@ -64,7 +63,7 @@ public class FlowViewHandler extends ViewHandler {
if (JsfUtils.isFlowRequest()) {
return RequestContextHolder.getRequestContext().getExternalContext().getLocale();
} else {
- return delegate.calculateLocale(context);
+ return super.calculateLocale(context);
}
}
@@ -73,7 +72,7 @@ public class FlowViewHandler extends ViewHandler {
if (JsfUtils.isFlowRequest()) {
resourcePath = resolveResourcePath(RequestContextHolder.getRequestContext(), viewId);
}
- return delegate.createView(context, resourcePath);
+ return super.createView(context, resourcePath);
}
public UIViewRoot restoreView(FacesContext context, String viewId) {
@@ -82,37 +81,17 @@ public class FlowViewHandler extends ViewHandler {
resourcePath = resolveResourcePath(RequestContextHolder.getRequestContext(), viewId);
return restoreFlowView(context, resourcePath);
}
- return delegate.restoreView(context, resourcePath);
- }
-
- // ------------------- Pass-through delegate methods ------------------//
-
- public String calculateRenderKitId(FacesContext context) {
- return delegate.calculateRenderKitId(context);
- }
-
- public String getResourceURL(FacesContext context, String path) {
- return delegate.getResourceURL(context, path);
- }
-
- public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
- delegate.renderView(context, viewToRender);
- }
-
- public void writeState(FacesContext context) throws IOException {
- delegate.writeState(context);
+ return super.restoreView(context, resourcePath);
}
public String deriveViewId(FacesContext context, String rawViewId) {
if (JsfUtils.isFlowRequest()) {
return resolveResourcePath(RequestContextHolder.getRequestContext(), rawViewId);
} else {
- return getDelegate().deriveViewId(context, rawViewId);
+ return super.deriveViewId(context, rawViewId);
}
}
- // --------------------- Private Helpers ------------------------------//
-
private String resolveResourcePath(RequestContext context, String viewId) {
if (viewId.startsWith("/")) {
return viewId;
@@ -141,8 +120,7 @@ public class FlowViewHandler extends ViewHandler {
if (holder != null && holder.getViewRoot() != null && holder.getViewRoot().getViewId().equals(resourcePath)) {
return holder.getViewRoot();
} else {
- return delegate.restoreView(facesContext, resourcePath);
+ return super.restoreView(facesContext, resourcePath);
}
}
-
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java
deleted file mode 100644
index fc2fa4e7..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2004-2011 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import java.io.IOException;
-
-import javax.faces.application.StateManager;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.webflow.execution.RequestContext;
-import org.springframework.webflow.execution.RequestContextHolder;
-
-/**
- * Custom {@link StateManager} that manages the JSF component state in web flow's view scope.
- *
- * @author Jeremy Grelle
- * @author Rossen Stoyanchev
- */
-public class FlowViewStateManager extends StateManager {
-
- private static final Log logger = LogFactory.getLog(FlowViewStateManager.class);
-
- protected static final String SERIALIZED_VIEW_STATE = "flowSerializedViewState";
-
- private StateManager delegate;
-
- public FlowViewStateManager(StateManager delegate) {
- this.delegate = delegate;
- }
-
- protected Object getComponentStateToSave(FacesContext context) {
- if (!JsfUtils.isFlowRequest()) {
- return super.getComponentStateToSave(context);
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (viewRoot.isTransient()) {
- return null;
- } else {
- return viewRoot.processSaveState(context);
- }
- }
-
- protected Object getTreeStructureToSave(FacesContext context) {
- if (!JsfUtils.isFlowRequest()) {
- return super.getTreeStructureToSave(context);
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (viewRoot.isTransient()) {
- return null;
- } else {
- return new TreeStructureManager().buildTreeStructureToSave(viewRoot);
- }
- }
-
- protected void restoreComponentState(FacesContext context, UIViewRoot viewRoot, String renderKitId) {
- if (!JsfUtils.isFlowRequest()) {
- super.restoreComponentState(context, viewRoot, renderKitId);
- return;
- }
- RequestContext requestContext = RequestContextHolder.getRequestContext();
- FlowSerializedView view = (FlowSerializedView) requestContext.getViewScope().get(SERIALIZED_VIEW_STATE);
- viewRoot.processRestoreState(context, view.getComponentState());
- logger.debug("UIViewRoot component state restored");
- }
-
- protected UIViewRoot restoreTreeStructure(FacesContext context, String viewId, String renderKitId) {
- if (!JsfUtils.isFlowRequest()) {
- return super.restoreTreeStructure(context, viewId, renderKitId);
- }
- RequestContext requestContext = RequestContextHolder.getRequestContext();
- FlowSerializedView view = (FlowSerializedView) requestContext.getViewScope().get(SERIALIZED_VIEW_STATE);
- if (view == null || !view.getViewId().equals(viewId)) {
- logger.debug("No matching view in view scope");
- return null;
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Restoring view root with id '" + viewId + "' from view scope");
- }
- if (view.getTreeStructure() == null) {
- logger.debug("Tree structure is null indicating transient UIViewRoot; returning null");
- return null;
- }
- UIViewRoot viewRoot = new TreeStructureManager().restoreTreeStructure(view.getTreeStructure());
- logger.debug("UIViewRoot structure restored");
- return viewRoot;
- }
-
- public void writeState(FacesContext context, javax.faces.application.StateManager.SerializedView state)
- throws IOException {
- // Ensures that javax.faces.ViewState hidden field always gets written - needed for third-party component
- // compatibility
- delegate.writeState(context, state);
- }
-
- public void writeState(FacesContext context, Object state) throws IOException {
- if (state instanceof Object[]) {
- delegate.writeState(context, state); // MyFaces
- } else if (state instanceof FlowSerializedView) { // Mojarra
- FlowSerializedView view = (FlowSerializedView) state;
- delegate.writeState(context, view.asTreeStructAndCompStateArray());
- } else {
- super.writeState(context, state);
- }
- }
-
- public boolean isSavingStateInClient(FacesContext context) {
- if (!JsfUtils.isFlowRequest()) {
- return delegate.isSavingStateInClient(context);
- } else {
- return false;
- }
- }
-
- /**
- * JSF 1.1 version of state saving
- */
- public javax.faces.application.StateManager.SerializedView saveSerializedView(FacesContext context) {
- if (context.getViewRoot().isTransient()) {
- return null;
- }
- if (!JsfUtils.isFlowRequest()) {
- return delegate.saveSerializedView(context);
- }
- Object state = saveView(context);
- if (state instanceof FlowSerializedView) {
- FlowSerializedView serializedState = (FlowSerializedView) state;
- return new javax.faces.application.StateManager.SerializedView(serializedState.getTreeStructure(),
- serializedState.getComponentState());
- } else {
- Object[] serializedState = (Object[]) state;
- return new javax.faces.application.StateManager.SerializedView(serializedState[0], serializedState[1]);
- }
- }
-
- /**
- *
- * JSF 1.2 (or higher) version of state saving.
- *
- *
- * In JSF 2, if partial state saving is enabled this method delegates in order to obtain the serialized view state.
- * During rendering JSF calls this method to prepare the state and then calls {@link FlowViewResponseStateManager}
- * which writes it to Web Flow's view scope.
- *
- *
- * Nevertheless this method always writes the serialized state to Web Flow's view scope to ensure it is up-to-date
- * for cases outside of rendering (e.g. ViewState.updateHistory()) or when the render phase doesn't call
- * {@link FlowViewResponseStateManager} such as when processing a partial request.
- */
- public Object saveView(FacesContext context) {
- if (context.getViewRoot().isTransient()) {
- return null;
- }
- if (!JsfUtils.isFlowRequest()) {
- return delegate.saveView(context);
- }
- FlowSerializedView view = null;
- if (JsfRuntimeInformation.isPartialStateSavingSupported()) {
- Object[] state = (Object[]) delegate.saveView(context);
- view = new FlowSerializedView(context.getViewRoot().getViewId(), state[0], state[1]);
- } else {
- view = new FlowSerializedView(context.getViewRoot().getViewId(), getTreeStructureToSave(context),
- getComponentStateToSave(context));
- }
- RequestContext requestContext = RequestContextHolder.getRequestContext();
- if (logger.isDebugEnabled()) {
- logger.debug("Saving view root '" + context.getViewRoot().getViewId() + "' in view scope");
- }
- requestContext.getViewScope().put(SERIALIZED_VIEW_STATE, view);
- return view;
- }
-
- /**
- *
- * In JSF 2 where a partial state saving algorithm is used, this method merely delegates to the next
- * ViewStateManager. Thus partial state saving is handled by the JSF 2 runtime. However, a
- * {@link FlowViewResponseStateManager} plugged in via {@link FlowRenderKit} will ensure the state is saved in a Web
- * Flow view-scoped variable.
- *
- */
- public UIViewRoot restoreView(FacesContext context, String viewId, String renderKitId) {
- if ((!JsfUtils.isFlowRequest()) || JsfRuntimeInformation.isPartialStateSavingSupported()) {
- return delegate.restoreView(context, viewId, renderKitId);
- } else {
- UIViewRoot viewRoot = restoreTreeStructure(context, viewId, renderKitId);
- if (viewRoot != null) {
- context.setViewRoot(viewRoot);
- restoreComponentState(context, viewRoot, renderKitId);
- }
- return viewRoot;
- }
- }
-
- @Override
- public String getViewState(FacesContext context) {
- if (!JsfUtils.isFlowRequest()) {
- return delegate.getViewState(context);
- }
- /*
- * Mojarra 2: PartialRequestContextImpl.renderState() invokes this method during Ajax request rendering. We
- * overridde it to convert FlowSerializedView state to an array before calling the
- * ResponseStateManager.getViewState(), which in turn calls the ServerSideStateHelper and expects state to be an
- * array.
- */
- Object state = saveView(context);
- if (state != null) {
- if (state instanceof FlowSerializedView) {
- FlowSerializedView view = (FlowSerializedView) state;
- state = view.asTreeStructAndCompStateArray();
- }
- return context.getRenderKit().getResponseStateManager().getViewState(context, state);
- }
- return null;
- }
-
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowApplication.java b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowApplication.java
deleted file mode 100644
index 12f5048c..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowApplication.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2004-2010 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.application.Application;
-import javax.faces.application.ProjectStage;
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
-
-/**
- * Extends FlowApplication in order to provide JSF 2 delegation method. This is necessary because some of the methods
- * use JSF 2 specific types as input or output parameters.
- *
- * @author Rossen Stoyanchev
- */
-public class Jsf2FlowApplication extends FlowApplication {
-
- public Jsf2FlowApplication(Application delegate) {
- super(delegate);
- }
-
- // ------------------- JSF 2 pass-through delegate methods ------------------//
-
- public void addBehavior(String behaviorId, String behaviorClass) {
- getDelegate().addBehavior(behaviorId, behaviorClass);
- }
-
- public void addDefaultValidatorId(String validatorId) {
- getDelegate().addDefaultValidatorId(validatorId);
- }
-
- public Behavior createBehavior(String behaviorId) throws FacesException {
- return getDelegate().createBehavior(behaviorId);
- }
-
- public UIComponent createComponent(FacesContext context, Resource componentResource) {
- return getDelegate().createComponent(context, componentResource);
- }
-
- public UIComponent createComponent(FacesContext context, String componentType, String rendererType) {
- return getDelegate().createComponent(context, componentType, rendererType);
- }
-
- public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType,
- String rendererType) {
- return getDelegate().createComponent(componentExpression, context, componentType, rendererType);
- }
-
- public Iterator getBehaviorIds() {
- return getDelegate().getBehaviorIds();
- }
-
- public Map getDefaultValidatorInfo() {
- return getDelegate().getDefaultValidatorInfo();
- }
-
- public ProjectStage getProjectStage() {
- return getDelegate().getProjectStage();
- }
-
- public ResourceHandler getResourceHandler() {
- return getDelegate().getResourceHandler();
- }
-
- public void publishEvent(FacesContext context, Class extends SystemEvent> systemEventClass,
- Class> sourceBaseType, Object source) {
- getDelegate().publishEvent(context, systemEventClass, sourceBaseType, source);
- }
-
- public void publishEvent(FacesContext context, Class extends SystemEvent> systemEventClass, Object source) {
- getDelegate().publishEvent(context, systemEventClass, source);
- }
-
- public void setResourceHandler(ResourceHandler resourceHandler) {
- getDelegate().setResourceHandler(resourceHandler);
- }
-
- public void subscribeToEvent(Class extends SystemEvent> systemEventClass, Class> sourceClass,
- SystemEventListener listener) {
- getDelegate().subscribeToEvent(systemEventClass, sourceClass, listener);
- }
-
- public void subscribeToEvent(Class extends SystemEvent> systemEventClass, SystemEventListener listener) {
- getDelegate().subscribeToEvent(systemEventClass, listener);
- }
-
- public void unsubscribeFromEvent(Class extends SystemEvent> systemEventClass, Class> sourceClass,
- SystemEventListener listener) {
- getDelegate().unsubscribeFromEvent(systemEventClass, sourceClass, listener);
- }
-
- public void unsubscribeFromEvent(Class extends SystemEvent> systemEventClass, SystemEventListener listener) {
- getDelegate().unsubscribeFromEvent(systemEventClass, listener);
- }
-
- // Ideally this method should be in JsfView
- // We keep it here to avoid ClassNotFoundExceptions for JSF 1.2 apps
-
- static void publishPostRestoreStateEvent() {
- FacesContext facesContext = FlowFacesContext.getCurrentInstance();
- try {
- facesContext.getViewRoot().visitTree(VisitContext.createVisitContext(facesContext),
- new PostRestoreStateEventVisitCallback());
- } catch (AbortProcessingException e) {
- facesContext.getApplication().publishEvent(facesContext, ExceptionQueuedEvent.class,
- new ExceptionQueuedEventContext(facesContext, e, null, facesContext.getCurrentPhaseId()));
- }
- }
-}
diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java
deleted file mode 100644
index 6ae2b56a..00000000
--- a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2004-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.faces.webflow;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.FacesMessage;
-import javax.faces.application.ProjectStage;
-import javax.faces.context.ExceptionHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.Flash;
-import javax.faces.context.PartialViewContext;
-import javax.faces.context.PartialViewContextFactory;
-import javax.faces.event.PhaseId;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.webflow.execution.RequestContext;
-
-/**
- * Extends FlowFacesContext in order to provide JSF 2 delegation method.
- *
- * @author Rossen Stoyanchev
- */
-public class Jsf2FlowFacesContext extends FlowFacesContext {
-
- private ExternalContext externalContext;
-
- private PartialViewContext partialViewContext;
-
- public Jsf2FlowFacesContext(RequestContext context, FacesContext delegate) {
- super(context, delegate);
-
- this.externalContext = new Jsf2FlowExternalContext(getDelegate().getExternalContext());
-
- PartialViewContextFactory factory = (PartialViewContextFactory) FactoryFinder
- .getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
- PartialViewContext partialViewContextDelegate = factory.getPartialViewContext(this);
- this.partialViewContext = new FlowPartialViewContext(partialViewContextDelegate);
- }
-
- public ExternalContext getExternalContext() {
- return externalContext;
- }
-
- // --------------- JSF 2.0 Pass-through delegate methods ------------------//
-
- public Map