Refactor code to use Java 5 features
- Apply and use Generics - Remove JdkVersion.isAtLeastJava15() conditionals - Replace iterator loops with foreach syntax - Switch on warning in eclipse Issues: SWF-1532
This commit is contained in:
@@ -65,8 +65,8 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle
|
||||
parserContext.pushContainingComponent(componentDefinition);
|
||||
|
||||
parseConversionService(element, parserContext, definitionBuilder);
|
||||
parseExpressionParser(element, parserContext, definitionBuilder, parseEnableManagedBeans(element,
|
||||
definitionBuilder));
|
||||
parseExpressionParser(element, parserContext, definitionBuilder,
|
||||
parseEnableManagedBeans(element, definitionBuilder));
|
||||
parseViewFactoryCreator(element, parserContext, definitionBuilder);
|
||||
parseDevelopment(element, definitionBuilder);
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ 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;
|
||||
@@ -37,9 +39,9 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
|
||||
public Class<?> getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
|
||||
ELContext elContext = new SimpleELContext(delegate);
|
||||
Class type = elContext.getELResolver().getType(elContext, base, new Integer(index));
|
||||
Class<?> type = elContext.getELResolver().getType(elContext, base, new Integer(index));
|
||||
if (elContext.isPropertyResolved()) {
|
||||
return type;
|
||||
} else {
|
||||
@@ -47,9 +49,9 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
|
||||
}
|
||||
}
|
||||
|
||||
public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
|
||||
public Class<?> getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
|
||||
ELContext elContext = new SimpleELContext(delegate);
|
||||
Class type = elContext.getELResolver().getType(elContext, base, property);
|
||||
Class<?> type = elContext.getELResolver().getType(elContext, base, property);
|
||||
if (elContext.isPropertyResolved()) {
|
||||
return type;
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,9 @@ 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;
|
||||
|
||||
@@ -28,19 +28,19 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class ManySelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware {
|
||||
public class ManySelectionTrackingListDataModel<T> extends SerializableListDataModel<T> implements SelectionAware<T> {
|
||||
|
||||
private List selections = new ArrayList();
|
||||
private List<T> selections = new ArrayList<T>();
|
||||
|
||||
public ManySelectionTrackingListDataModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ManySelectionTrackingListDataModel(List list) {
|
||||
public ManySelectionTrackingListDataModel(List<T> list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
public List getSelections() {
|
||||
public List<T> getSelections() {
|
||||
return selections;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataMode
|
||||
|
||||
public void selectAll() {
|
||||
selections.clear();
|
||||
selections.addAll((List) getWrappedData());
|
||||
selections.addAll(getWrappedData());
|
||||
}
|
||||
|
||||
public void setCurrentRowSelected(boolean rowSelected) {
|
||||
@@ -64,13 +64,12 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataMode
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelections(List selections) {
|
||||
public void setSelections(List<T> selections) {
|
||||
this.selections = selections;
|
||||
}
|
||||
|
||||
public void select(Object rowData) {
|
||||
Assert.isTrue(((List) getWrappedData()).contains(rowData),
|
||||
"The object to select is not contained in this DataModel.");
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -27,22 +27,22 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class OneSelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware {
|
||||
public class OneSelectionTrackingListDataModel<T> extends SerializableListDataModel<T> implements SelectionAware<T> {
|
||||
|
||||
/**
|
||||
* The list of currently selected row data objects.
|
||||
*/
|
||||
private List selections = new ArrayList();
|
||||
private List<T> selections = new ArrayList<T>();
|
||||
|
||||
public OneSelectionTrackingListDataModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public OneSelectionTrackingListDataModel(List list) {
|
||||
public OneSelectionTrackingListDataModel(List<T> list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
public List getSelections() {
|
||||
public List<T> getSelections() {
|
||||
return selections;
|
||||
}
|
||||
|
||||
@@ -50,15 +50,14 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataModel
|
||||
return selections.contains(getRowData());
|
||||
}
|
||||
|
||||
public void select(Object rowData) {
|
||||
Assert.isTrue(((List) getWrappedData()).contains(rowData),
|
||||
"The object to select is not contained in this DataModel.");
|
||||
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);
|
||||
}
|
||||
|
||||
public void selectAll() {
|
||||
if (((List) getWrappedData()).size() > 1) {
|
||||
if ((getWrappedData()).size() > 1) {
|
||||
throw new UnsupportedOperationException("This DataModel only allows one selection.");
|
||||
}
|
||||
}
|
||||
@@ -76,7 +75,7 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataModel
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelections(List selections) {
|
||||
public void setSelections(List<T> selections) {
|
||||
Assert.isTrue(selections.size() <= 1, "This DataModel only allows one selection.");
|
||||
this.selections = selections;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.faces.model.DataModel;
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public interface SelectionAware {
|
||||
public interface SelectionAware<T> {
|
||||
|
||||
/**
|
||||
* Checks whether the row pointed to by the model's current index is selected.
|
||||
@@ -42,13 +42,13 @@ public interface SelectionAware {
|
||||
* Sets the list of selected row data objects for the model.
|
||||
* @param selections the list of selected row data objects
|
||||
*/
|
||||
public void setSelections(List selections);
|
||||
public void setSelections(List<T> selections);
|
||||
|
||||
/**
|
||||
* Returns the list of selected row data objects for the model.
|
||||
* @return the list of selected row data objects
|
||||
*/
|
||||
public List getSelections();
|
||||
public List<T> getSelections();
|
||||
|
||||
/**
|
||||
* Selects all row data objects in the model.
|
||||
@@ -59,5 +59,5 @@ public interface SelectionAware {
|
||||
* Selects the given row data object in the model.
|
||||
* @param rowData the row data object to select.
|
||||
*/
|
||||
public void select(Object rowData);
|
||||
public void select(T rowData);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SelectionTrackingActionListener implements ActionListener {
|
||||
if (valueAccessor != null) {
|
||||
Object value = ReflectionUtils.invokeMethod(valueAccessor, parent);
|
||||
if (value != null && value instanceof SelectionAware) {
|
||||
((SelectionAware) value).setCurrentRowSelected(true);
|
||||
((SelectionAware<?>) value).setCurrentRowSelected(true);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Row selection has been set on the current SelectionAware data model.");
|
||||
}
|
||||
|
||||
@@ -30,23 +30,23 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class SerializableListDataModel extends DataModel implements Serializable {
|
||||
public class SerializableListDataModel<T> extends DataModel<T> implements Serializable {
|
||||
|
||||
private int rowIndex = 0;
|
||||
|
||||
private List data;
|
||||
private List<T> data;
|
||||
|
||||
public SerializableListDataModel() {
|
||||
this(new ArrayList());
|
||||
this(new ArrayList<T>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the list to a data model;
|
||||
* @param list the list
|
||||
*/
|
||||
public SerializableListDataModel(List list) {
|
||||
public SerializableListDataModel(List<T> list) {
|
||||
if (list == null) {
|
||||
list = new ArrayList();
|
||||
list = new ArrayList<T>();
|
||||
}
|
||||
setWrappedData(list);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class SerializableListDataModel extends DataModel implements Serializable
|
||||
return data.size();
|
||||
}
|
||||
|
||||
public Object getRowData() {
|
||||
public T getRowData() {
|
||||
Assert.isTrue(isRowAvailable(), getClass()
|
||||
+ " is in an illegal state - no row is available at the current index.");
|
||||
return data.get(rowIndex);
|
||||
@@ -65,7 +65,7 @@ public class SerializableListDataModel extends DataModel implements Serializable
|
||||
return rowIndex;
|
||||
}
|
||||
|
||||
public Object getWrappedData() {
|
||||
public List<T> getWrappedData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -83,18 +83,19 @@ public class SerializableListDataModel extends DataModel implements Serializable
|
||||
Object row = isRowAvailable() ? getRowData() : null;
|
||||
DataModelEvent event = new DataModelEvent(this, rowIndex, row);
|
||||
DataModelListener[] listeners = getDataModelListeners();
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
listeners[i].rowSelected(event);
|
||||
for (DataModelListener listener : listeners) {
|
||||
listener.rowSelected(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setWrappedData(Object data) {
|
||||
if (data == null) {
|
||||
data = new ArrayList();
|
||||
data = new ArrayList<T>();
|
||||
}
|
||||
Assert.isInstanceOf(List.class, data, "The data object for " + getClass() + " must be a List");
|
||||
this.data = (List) data;
|
||||
this.data = (List<T>) data;
|
||||
int newRowIndex = 0;
|
||||
setRowIndex(newRowIndex);
|
||||
}
|
||||
|
||||
@@ -32,20 +32,20 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class DataModelConverter implements Converter {
|
||||
|
||||
public Class getSourceClass() {
|
||||
public Class<?> getSourceClass() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
public Class getTargetClass() {
|
||||
public Class<?> getTargetClass() {
|
||||
return DataModel.class;
|
||||
}
|
||||
|
||||
public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
if (targetClass.equals(DataModel.class)) {
|
||||
targetClass = OneSelectionTrackingListDataModel.class;
|
||||
}
|
||||
Constructor emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {});
|
||||
DataModel model = (DataModel) emptyConstructor.newInstance(new Object[] {});
|
||||
Constructor<?> emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {});
|
||||
DataModel<?> model = (DataModel<?>) emptyConstructor.newInstance(new Object[] {});
|
||||
model.setWrappedData(source);
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
@@ -53,8 +52,8 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
facesLifecycle = createFacesLifecycle();
|
||||
}
|
||||
|
||||
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
|
||||
FacesContextHelper facesContextHelper = new FacesContextHelper();
|
||||
FacesContext facesContext = facesContextHelper.getFacesContext(getServletContext(), request, response);
|
||||
@@ -89,20 +88,14 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
}
|
||||
}
|
||||
|
||||
private void populateRequestMap(FacesContext facesContext, Map model) {
|
||||
Iterator i = model.keySet().iterator();
|
||||
private void populateRequestMap(FacesContext facesContext, Map<String, Object> model) {
|
||||
Iterator<String> i = model.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
String key = i.next().toString();
|
||||
facesContext.getExternalContext().getRequestMap().put(key, model.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
private FacesContext createFacesContext(HttpServletRequest request, HttpServletResponse response) {
|
||||
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
|
||||
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
|
||||
return facesContextFactory.getFacesContext(getServletContext(), request, response, facesLifecycle);
|
||||
}
|
||||
|
||||
private Lifecycle createFacesLifecycle() {
|
||||
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
|
||||
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer
|
||||
|
||||
private String getElementId(FacesContext context, UIComponent component) {
|
||||
if (component.getChildCount() > 0) {
|
||||
UIComponent child = (UIComponent) component.getChildren().get(0);
|
||||
UIComponent child = component.getChildren().get(0);
|
||||
if (!(child instanceof SpringJavascriptElementDecoration)) {
|
||||
return child.getClientId(context);
|
||||
} else {
|
||||
@@ -81,8 +81,8 @@ public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer
|
||||
|
||||
public void decode(FacesContext context, UIComponent component) {
|
||||
if (context.getExternalContext().getRequestParameterMap().containsKey("ajaxSource")
|
||||
&& context.getExternalContext().getRequestParameterMap().get("ajaxSource").equals(
|
||||
component.getClientId(context))) {
|
||||
&& context.getExternalContext().getRequestParameterMap().get("ajaxSource")
|
||||
.equals(component.getClientId(context))) {
|
||||
component.queueEvent(new ActionEvent(component));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
|
||||
protected static final String PROCESS_ALL = "*";
|
||||
|
||||
private List events = new ArrayList();
|
||||
private List<FacesEvent> events = new ArrayList<FacesEvent>();
|
||||
|
||||
private String[] processIds;
|
||||
|
||||
@@ -165,8 +165,7 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
protected String[] getProcessIds() {
|
||||
if (processIds == null) {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String processIdsParam = (String) context.getExternalContext().getRequestParameterMap().get(
|
||||
PROCESS_IDS_PARAM);
|
||||
String processIdsParam = context.getExternalContext().getRequestParameterMap().get(PROCESS_IDS_PARAM);
|
||||
if (StringUtils.hasText(processIdsParam) && processIdsParam.indexOf(PROCESS_ALL) != -1) {
|
||||
processIds = new String[] { getOriginalViewRoot().getClientId(context) };
|
||||
} else {
|
||||
@@ -203,9 +202,9 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
// 3.2. adds outputScript to it
|
||||
// 3.3. the parent of outputScript is changed from ViewRoot to "head" Panel component
|
||||
// 4. outputScript is therefore no longer a child of ViewRoot
|
||||
List children = new ArrayList(target.getChildren());
|
||||
List<UIComponent> children = new ArrayList<UIComponent>(target.getChildren());
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
UIComponent child = (UIComponent) children.get(i);
|
||||
UIComponent child = children.get(i);
|
||||
child.setParent(target);
|
||||
}
|
||||
}
|
||||
@@ -242,10 +241,10 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
}
|
||||
|
||||
private String[] removeNestedChildren(FacesContext context, String[] ids) {
|
||||
List idList = Arrays.asList(ids);
|
||||
final List trimmedIds = new ArrayList(idList);
|
||||
for (final ListIterator i = trimmedIds.listIterator(); i.hasNext();) {
|
||||
String id = (String) i.next();
|
||||
List<String> idList = Arrays.asList(ids);
|
||||
final List<String> trimmedIds = new ArrayList<String>(idList);
|
||||
for (final ListIterator<String> i = trimmedIds.listIterator(); i.hasNext();) {
|
||||
String id = i.next();
|
||||
invokeOnComponent(context, id, new ContextCallback() {
|
||||
public void invokeContextCallback(FacesContext context, UIComponent component) {
|
||||
while (!(component.getParent() instanceof UIViewRoot)) {
|
||||
@@ -257,18 +256,19 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
}
|
||||
});
|
||||
}
|
||||
return (String[]) trimmedIds.toArray(new String[trimmedIds.size()]);
|
||||
return trimmedIds.toArray(new String[trimmedIds.size()]);
|
||||
}
|
||||
|
||||
private void broadCastEvents(FacesContext context, PhaseId phaseId) {
|
||||
List processedEvents = new ArrayList();
|
||||
if (events.size() == 0)
|
||||
List<FacesEvent> processedEvents = new ArrayList<FacesEvent>();
|
||||
if (events.size() == 0) {
|
||||
return;
|
||||
}
|
||||
boolean abort = false;
|
||||
int phaseIdOrdinal = phaseId.getOrdinal();
|
||||
Iterator i = events.iterator();
|
||||
Iterator<FacesEvent> i = events.iterator();
|
||||
while (i.hasNext()) {
|
||||
FacesEvent event = (FacesEvent) i.next();
|
||||
FacesEvent event = i.next();
|
||||
int ordinal = event.getPhaseId().getOrdinal();
|
||||
if (ordinal == PhaseId.ANY_PHASE.getOrdinal() || ordinal == phaseIdOrdinal) {
|
||||
UIComponent source = event.getComponent();
|
||||
|
||||
@@ -32,7 +32,7 @@ import javax.faces.render.Renderer;
|
||||
*/
|
||||
public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer {
|
||||
|
||||
private Map attributeCallbacks;
|
||||
private Map<String, RenderAttributeCallback> attributeCallbacks;
|
||||
|
||||
private RenderAttributeCallback idCallback = new RenderAttributeCallback() {
|
||||
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
|
||||
@@ -50,9 +50,9 @@ public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer {
|
||||
}
|
||||
};
|
||||
|
||||
protected Map getAttributeCallbacks(UIComponent component) {
|
||||
protected Map<String, RenderAttributeCallback> getAttributeCallbacks(UIComponent component) {
|
||||
if (attributeCallbacks == null) {
|
||||
attributeCallbacks = new HashMap();
|
||||
attributeCallbacks = new HashMap<String, RenderAttributeCallback>();
|
||||
attributeCallbacks.put("id", idCallback);
|
||||
attributeCallbacks.put("name", idCallback);
|
||||
attributeCallbacks.put("disabled", disabledCallback);
|
||||
|
||||
@@ -75,13 +75,13 @@ abstract class BaseHtmlTagRenderer extends Renderer {
|
||||
String attribute = getAttributesToRender(component)[i];
|
||||
String property = attribute;
|
||||
if (getAttributeAliases(component).containsKey(attribute)) {
|
||||
property = (String) getAttributeAliases(component).get(attribute);
|
||||
property = getAttributeAliases(component).get(attribute);
|
||||
}
|
||||
Object attributeValue = component.getAttributes().get(property);
|
||||
|
||||
RenderAttributeCallback callback = defaultRenderAttributeCallback;
|
||||
if (getAttributeCallbacks(null).containsKey(attribute)) {
|
||||
callback = (RenderAttributeCallback) getAttributeCallbacks(component).get(attribute);
|
||||
callback = getAttributeCallbacks(component).get(attribute);
|
||||
}
|
||||
callback.doRender(context, context.getResponseWriter(), component, attribute, attributeValue, property);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
@@ -113,15 +113,15 @@ abstract class BaseHtmlTagRenderer extends Renderer {
|
||||
* @return a map that returns the bean property name for any attribute that doesn't map directly (i.e., the 'class'
|
||||
* attribute maps to the 'styleClass' bean property)
|
||||
*/
|
||||
protected Map getAttributeAliases(UIComponent component) {
|
||||
protected Map<String, String> getAttributeAliases(UIComponent component) {
|
||||
return HTML.STANDARD_ATTRIBUTE_ALIASES;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return a map of registered RenderAttributeCallbacks for attributes that require special rendering logic
|
||||
*/
|
||||
protected Map getAttributeCallbacks(UIComponent component) {
|
||||
return Collections.EMPTY_MAP;
|
||||
protected Map<String, RenderAttributeCallback> getAttributeCallbacks(UIComponent component) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#getAttributes()
|
||||
*/
|
||||
public Map getAttributes() {
|
||||
public Map<String, Object> getAttributes() {
|
||||
return original.getAttributes();
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#getChildren()
|
||||
*/
|
||||
public List getChildren() {
|
||||
public List<UIComponent> getChildren() {
|
||||
return original.getChildren();
|
||||
}
|
||||
|
||||
@@ -195,14 +195,14 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#getFacets()
|
||||
*/
|
||||
public Map getFacets() {
|
||||
public Map<String, UIComponent> getFacets() {
|
||||
return original.getFacets();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#getFacetsAndChildren()
|
||||
*/
|
||||
public Iterator getFacetsAndChildren() {
|
||||
public Iterator<UIComponent> getFacetsAndChildren() {
|
||||
return original.getFacetsAndChildren();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,7 @@ public class DojoClientDateValidator extends DojoWidget {
|
||||
static {
|
||||
DOJO_ATTRS = new String[DojoWidget.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length];
|
||||
System.arraycopy(DojoWidget.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoWidget.DOJO_ATTRS.length);
|
||||
System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length,
|
||||
DOJO_ATTRS_INTERNAL.length);
|
||||
System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length, DOJO_ATTRS_INTERNAL.length);
|
||||
}
|
||||
|
||||
public String getDatePattern() {
|
||||
|
||||
@@ -60,10 +60,11 @@ public class DojoElementDecorationRenderer extends BaseSpringJavascriptDecoratio
|
||||
if (component.getAttributes().containsKey("selector")) {
|
||||
selector = "\"" + (String) component.getAttributes().get("selector") + "\"";
|
||||
} else {
|
||||
if (component.getChildCount() == 0)
|
||||
if (component.getChildCount() == 0) {
|
||||
throw new FacesException(
|
||||
"A Spring Faces elementDecoration expects either have a specified selector or at least one child component.");
|
||||
selector = "dojo.byId('" + ((UIComponent) component.getChildren().get(0)).getClientId(context) + "')";
|
||||
}
|
||||
selector = "dojo.byId('" + component.getChildren().get(0).getClientId(context) + "')";
|
||||
}
|
||||
|
||||
ResourceHelper.beginScriptBlock(context);
|
||||
|
||||
@@ -24,7 +24,6 @@ import javax.faces.el.ValueBinding;
|
||||
* component with enhanced client-side behavior.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
*/
|
||||
public abstract class DojoWidget extends SpringJavascriptElementDecoration {
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ public class DojoWidgetRenderer extends DojoElementDecorationRenderer {
|
||||
|
||||
if (value != null) {
|
||||
|
||||
if (attrs.length() > 0)
|
||||
if (attrs.length() > 0) {
|
||||
attrs.append(", ");
|
||||
}
|
||||
|
||||
attrs.append(key + " : ");
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ final class HTML {
|
||||
public static final String[] STANDARD_ATTRIBUTES = new String[] { "id", "class", "style", "title", "dir", "lang",
|
||||
"accesskey", "tabindex" };
|
||||
|
||||
public static final Map STANDARD_ATTRIBUTE_ALIASES = new HashMap();
|
||||
public static final Map<String, String> STANDARD_ATTRIBUTE_ALIASES = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Standard window events - only valid in body and frameset elements
|
||||
@@ -67,7 +67,7 @@ final class HTML {
|
||||
/**
|
||||
* Anchor attributes
|
||||
*/
|
||||
public static final Object[] ANCHOR_ATTRIBUTES = new String[] { "charset", "coords", "href", "hreflang", "name",
|
||||
public static final String[] ANCHOR_ATTRIBUTES = new String[] { "charset", "coords", "href", "hreflang", "name",
|
||||
"rel", "rev", "shape", "target", "type" };
|
||||
|
||||
static {
|
||||
|
||||
@@ -46,20 +46,20 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
|
||||
private static String INPUT_TAG_NAME = "input";
|
||||
|
||||
static {
|
||||
List tempList = new ArrayList();
|
||||
List<String> tempList = new ArrayList<String>();
|
||||
tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
|
||||
tempList.addAll(Arrays.asList(HTML.BUTTON_ATTRIBUTES));
|
||||
tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
|
||||
tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
|
||||
tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
|
||||
ATTRIBUTES_TO_RENDER = new String[tempList.size()];
|
||||
ListIterator i = tempList.listIterator();
|
||||
ListIterator<String> i = tempList.listIterator();
|
||||
while (i.hasNext()) {
|
||||
ATTRIBUTES_TO_RENDER[i.nextIndex()] = (String) i.next();
|
||||
ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next();
|
||||
}
|
||||
}
|
||||
|
||||
private Map attributeCallbacks;
|
||||
private Map<String, RenderAttributeCallback> attributeCallbacks;
|
||||
|
||||
private RenderAttributeCallback onclickCallback = new RenderAttributeCallback() {
|
||||
|
||||
@@ -98,9 +98,9 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
|
||||
|
||||
};
|
||||
|
||||
protected Map getAttributeCallbacks(UIComponent component) {
|
||||
protected Map<String, RenderAttributeCallback> getAttributeCallbacks(UIComponent component) {
|
||||
if (attributeCallbacks == null) {
|
||||
attributeCallbacks = new HashMap();
|
||||
attributeCallbacks = new HashMap<String, RenderAttributeCallback>();
|
||||
attributeCallbacks.putAll(super.getAttributeCallbacks(component));
|
||||
attributeCallbacks.put("onclick", onclickCallback);
|
||||
}
|
||||
|
||||
@@ -59,26 +59,26 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
|
||||
|
||||
static {
|
||||
|
||||
List tempList = new ArrayList();
|
||||
List<String> tempList = new ArrayList<String>();
|
||||
tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
|
||||
tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
|
||||
tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
|
||||
tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
|
||||
ATTRIBUTES_TO_RENDER_WHEN_DISABLED = new String[tempList.size()];
|
||||
ListIterator i = tempList.listIterator();
|
||||
ListIterator<String> i = tempList.listIterator();
|
||||
while (i.hasNext()) {
|
||||
ATTRIBUTES_TO_RENDER_WHEN_DISABLED[i.nextIndex()] = (String) i.next();
|
||||
ATTRIBUTES_TO_RENDER_WHEN_DISABLED[i.nextIndex()] = i.next();
|
||||
}
|
||||
|
||||
tempList.addAll(Arrays.asList(HTML.ANCHOR_ATTRIBUTES));
|
||||
ATTRIBUTES_TO_RENDER = new String[tempList.size()];
|
||||
i = tempList.listIterator();
|
||||
while (i.hasNext()) {
|
||||
ATTRIBUTES_TO_RENDER[i.nextIndex()] = (String) i.next();
|
||||
ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next();
|
||||
}
|
||||
}
|
||||
|
||||
private Map attributeCallbacks;
|
||||
private Map<String, RenderAttributeCallback> attributeCallbacks;
|
||||
|
||||
private RenderAttributeCallback hrefCallback = new RenderAttributeCallback() {
|
||||
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
|
||||
@@ -204,9 +204,9 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
|
||||
return isProgressiveCommandDisabled(component) ? TAG_NAME_WHEN_DISABLED : TAG_NAME;
|
||||
}
|
||||
|
||||
protected Map getAttributeCallbacks(UIComponent component) {
|
||||
protected Map<String, RenderAttributeCallback> getAttributeCallbacks(UIComponent component) {
|
||||
if (attributeCallbacks == null) {
|
||||
attributeCallbacks = new HashMap();
|
||||
attributeCallbacks = new HashMap<String, RenderAttributeCallback>();
|
||||
attributeCallbacks.putAll(super.getAttributeCallbacks(component));
|
||||
attributeCallbacks.put("href", hrefCallback);
|
||||
attributeCallbacks.put("class", classCallback);
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
* type conversion.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
*/
|
||||
public class ProgressiveUICommand extends UICommand {
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.util.Assert;
|
||||
* </p>
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
*/
|
||||
public class ResourceRenderer extends Renderer {
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ValidateAllRenderer extends BaseSpringJavascriptDecorationRenderer
|
||||
throw new FacesException("ValidateAll expects to have a child of type UICommand.");
|
||||
}
|
||||
|
||||
UIComponent advisedChild = (UIComponent) component.getChildren().get(0);
|
||||
UIComponent advisedChild = component.getChildren().get(0);
|
||||
|
||||
ResourceHelper.beginScriptBlock(context);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ResourceHelper {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void renderScriptLink(FacesContext facesContext, String scriptPath) throws IOException {
|
||||
renderScriptLink(facesContext, scriptPath, Collections.EMPTY_MAP);
|
||||
renderScriptLink(facesContext, scriptPath, Collections.<String, Object> emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public class ResourceHelper {
|
||||
* @param attributes - a map of additional attributes to render on the script tag
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void renderScriptLink(FacesContext facesContext, String scriptPath, Map attributes)
|
||||
public static void renderScriptLink(FacesContext facesContext, String scriptPath, Map<String, Object> attributes)
|
||||
throws IOException {
|
||||
if (alreadyRendered(facesContext, scriptPath)) {
|
||||
return;
|
||||
@@ -92,9 +92,9 @@ public class ResourceHelper {
|
||||
ResponseWriter writer = facesContext.getResponseWriter();
|
||||
writer.startElement(SCRIPT_ELEMENT, null);
|
||||
writer.writeAttribute("type", "text/javascript", null);
|
||||
Iterator i = attributes.keySet().iterator();
|
||||
Iterator<String> i = attributes.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
String key = (String) i.next();
|
||||
String key = i.next();
|
||||
writer.writeAttribute(key, attributes.get(key), null);
|
||||
}
|
||||
String src = facesContext.getExternalContext().getRequestContextPath() + "/resources" + scriptPath;
|
||||
@@ -145,7 +145,7 @@ public class ResourceHelper {
|
||||
}
|
||||
|
||||
public static void beginCombineStyles(FacesContext facesContext) {
|
||||
List combinedResources = new ArrayList();
|
||||
List<String> combinedResources = new ArrayList<String>();
|
||||
facesContext.getExternalContext().getRequestMap().put(COMBINED_RESOURCES_KEY, combinedResources);
|
||||
}
|
||||
|
||||
@@ -154,16 +154,15 @@ public class ResourceHelper {
|
||||
}
|
||||
|
||||
private static void addStyle(FacesContext facesContext, String stylePath) {
|
||||
List combinedResources = (List) facesContext.getExternalContext().getRequestMap().get(COMBINED_RESOURCES_KEY);
|
||||
List<String> combinedResources = getCombinedResources(facesContext);
|
||||
combinedResources.add(stylePath);
|
||||
}
|
||||
|
||||
public static void endCombineStyles(FacesContext facesContext) throws IOException {
|
||||
List combinedResources = (List) facesContext.getExternalContext().getRequestMap()
|
||||
.remove(COMBINED_RESOURCES_KEY);
|
||||
List<String> combinedResources = getCombinedResources(facesContext);
|
||||
StringBuffer combinedPath = new StringBuffer();
|
||||
for (int i = 0; i < combinedResources.size(); i++) {
|
||||
String resourcePath = (String) combinedResources.get(i);
|
||||
String resourcePath = combinedResources.get(i);
|
||||
if (i == 1) {
|
||||
combinedPath.append("?appended=");
|
||||
}
|
||||
@@ -189,17 +188,28 @@ public class ResourceHelper {
|
||||
}
|
||||
|
||||
private static void markRendered(FacesContext facesContext, String scriptPath) {
|
||||
Set renderedResources = (Set) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY);
|
||||
Set<String> renderedResources = getRenderedResources(facesContext);
|
||||
if (renderedResources == null) {
|
||||
renderedResources = new HashSet();
|
||||
renderedResources = new HashSet<String>();
|
||||
facesContext.getExternalContext().getRequestMap().put(RENDERED_RESOURCES_KEY, renderedResources);
|
||||
}
|
||||
renderedResources.add(scriptPath);
|
||||
}
|
||||
|
||||
private static boolean alreadyRendered(FacesContext facesContext, String scriptPath) {
|
||||
Set renderedResources = (Set) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY);
|
||||
Set<String> renderedResources = getRenderedResources(facesContext);
|
||||
return renderedResources != null && renderedResources.contains(scriptPath);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<String> getCombinedResources(FacesContext facesContext) {
|
||||
return (List<String>) facesContext.getExternalContext().getRequestMap().get(COMBINED_RESOURCES_KEY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Set<String> getRenderedResources(FacesContext facesContext) {
|
||||
return (Set<String>) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.encodeResourceURL(url);
|
||||
}
|
||||
|
||||
public Map getApplicationMap() {
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
return delegate.getApplicationMap();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.getInitParameter(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Map getInitParameterMap() {
|
||||
return delegate.getInitParameterMap();
|
||||
}
|
||||
@@ -77,15 +78,15 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.getRequestContextPath();
|
||||
}
|
||||
|
||||
public Map getRequestCookieMap() {
|
||||
public Map<String, Object> getRequestCookieMap() {
|
||||
return delegate.getRequestCookieMap();
|
||||
}
|
||||
|
||||
public Map getRequestHeaderMap() {
|
||||
public Map<String, String> getRequestHeaderMap() {
|
||||
return delegate.getRequestHeaderMap();
|
||||
}
|
||||
|
||||
public Map getRequestHeaderValuesMap() {
|
||||
public Map<String, String[]> getRequestHeaderValuesMap() {
|
||||
return delegate.getRequestHeaderValuesMap();
|
||||
}
|
||||
|
||||
@@ -93,23 +94,23 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.getRequestLocale();
|
||||
}
|
||||
|
||||
public Iterator getRequestLocales() {
|
||||
public Iterator<Locale> getRequestLocales() {
|
||||
return delegate.getRequestLocales();
|
||||
}
|
||||
|
||||
public Map getRequestMap() {
|
||||
public Map<String, Object> getRequestMap() {
|
||||
return delegate.getRequestMap();
|
||||
}
|
||||
|
||||
public Map getRequestParameterMap() {
|
||||
public Map<String, String> getRequestParameterMap() {
|
||||
return delegate.getRequestParameterMap();
|
||||
}
|
||||
|
||||
public Iterator getRequestParameterNames() {
|
||||
public Iterator<String> getRequestParameterNames() {
|
||||
return delegate.getRequestParameterNames();
|
||||
}
|
||||
|
||||
public Map getRequestParameterValuesMap() {
|
||||
public Map<String, String[]> getRequestParameterValuesMap() {
|
||||
return delegate.getRequestParameterValuesMap();
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.getResourceAsStream(path);
|
||||
}
|
||||
|
||||
public Set getResourcePaths(String path) {
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
return delegate.getResourcePaths(path);
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ class ExternalContextWrapper extends ExternalContext {
|
||||
return delegate.getSession(create);
|
||||
}
|
||||
|
||||
public Map getSessionMap() {
|
||||
public Map<String, Object> getSessionMap() {
|
||||
return delegate.getSessionMap();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class FlowActionListener implements ActionListener {
|
||||
if (requestContext.getMessageContext().hasErrorMessages()) {
|
||||
isValid = false;
|
||||
if (requestContext.getExternalContext().isAjaxRequest()) {
|
||||
List fragments = new ArrayList();
|
||||
List<String> fragments = new ArrayList<String>();
|
||||
String formId = getModelExpression(requestContext).getExpressionString();
|
||||
if (facesContext.getViewRoot().findComponent(formId) != null) {
|
||||
fragments.add(formId);
|
||||
@@ -118,7 +118,7 @@ public class FlowActionListener implements ActionListener {
|
||||
if (fragments.size() > 0) {
|
||||
String[] fragmentsArray = new String[fragments.size()];
|
||||
for (int i = 0; i < fragments.size(); i++) {
|
||||
fragmentsArray[i] = (String) fragments.get(i);
|
||||
fragmentsArray[i] = fragments.get(i);
|
||||
}
|
||||
requestContext.getFlashScope().put(View.RENDER_FRAGMENTS_ATTRIBUTE, fragmentsArray);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.springframework.webflow.execution.RequestContext;
|
||||
* requests in the case of the POST+REDIRECT+GET pattern being enabled.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
* @author Phil Webb
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class FlowFacesContext extends FacesContext {
|
||||
|
||||
@@ -109,10 +109,10 @@ public class FlowFacesContext extends FacesContext {
|
||||
}
|
||||
|
||||
public ELContext getELContext() {
|
||||
Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext", null);
|
||||
Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext");
|
||||
if (delegateMethod != null) {
|
||||
try {
|
||||
ELContext context = (ELContext) delegateMethod.invoke(delegate, null);
|
||||
ELContext context = (ELContext) delegateMethod.invoke(delegate);
|
||||
context.putContext(FacesContext.class, this);
|
||||
return context;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -29,7 +29,7 @@ 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 Phil Webb
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class FlowFacesContextMessageDelegate {
|
||||
|
||||
@@ -48,9 +48,9 @@ public class FlowFacesContextMessageDelegate {
|
||||
/**
|
||||
* Mappings between {@link FacesMessage} and {@link Severity}.
|
||||
*/
|
||||
private static final Map FACESSEVERITY_TO_SPRINGSEVERITY;
|
||||
private static final Map<FacesMessage.Severity, Severity> FACESSEVERITY_TO_SPRINGSEVERITY;
|
||||
static {
|
||||
FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap();
|
||||
FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap<FacesMessage.Severity, Severity>();
|
||||
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);
|
||||
@@ -95,14 +95,15 @@ public class FlowFacesContextMessageDelegate {
|
||||
return null;
|
||||
}
|
||||
FacesMessage.Severity max = FacesMessage.SEVERITY_INFO;
|
||||
Iterator i = getMessages();
|
||||
Iterator<FacesMessage> i = getMessages();
|
||||
while (i.hasNext()) {
|
||||
FacesMessage message = (FacesMessage) i.next();
|
||||
FacesMessage message = i.next();
|
||||
if (message.getSeverity().getOrdinal() > max.getOrdinal()) {
|
||||
max = message.getSeverity();
|
||||
}
|
||||
if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal())
|
||||
if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
@@ -174,8 +175,8 @@ public class FlowFacesContextMessageDelegate {
|
||||
for (int i = 0; i < summaryMessages.length; i++) {
|
||||
messages.add(toFacesMessage(summaryMessages[i], detailMessages[i]));
|
||||
}
|
||||
for (int z = 0; z < userMessages.length; z++) {
|
||||
messages.add(toFacesMessage(userMessages[z], userMessages[z]));
|
||||
for (Message userMessage : userMessages) {
|
||||
messages.add(toFacesMessage(userMessage, userMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,8 +189,8 @@ public class FlowFacesContextMessageDelegate {
|
||||
for (int i = 0; i < summaryMessages.length; i++) {
|
||||
messages.add(toFacesMessage(summaryMessages[i], detailMessages[i]));
|
||||
}
|
||||
for (int z = 0; z < userMessages.length; z++) {
|
||||
messages.add(toFacesMessage(userMessages[z], userMessages[z]));
|
||||
for (Message userMessage : userMessages) {
|
||||
messages.add(toFacesMessage(userMessage, userMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +337,7 @@ public class FlowFacesContextMessageDelegate {
|
||||
String detail = (String) ois.readObject();
|
||||
int severityOrdinal = ois.readInt();
|
||||
FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO;
|
||||
for (Iterator iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<?> iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
|
||||
FacesMessage.Severity value = (FacesMessage.Severity) iterator.next();
|
||||
if (value.getOrdinal() == severityOrdinal) {
|
||||
severity = value;
|
||||
@@ -381,7 +382,7 @@ public class FlowFacesContextMessageDelegate {
|
||||
public Severity getSeverity() {
|
||||
Severity severity = null;
|
||||
if (facesMessage.getSeverity() != null) {
|
||||
severity = (Severity) FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity());
|
||||
severity = FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity());
|
||||
}
|
||||
return (severity == null ? Severity.INFO : severity);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FlowLifecycle extends Lifecycle {
|
||||
public void execute(FacesContext context) throws FacesException {
|
||||
logger.debug("Executing view post back lifecycle");
|
||||
for (int p = PhaseId.APPLY_REQUEST_VALUES.getOrdinal(); p <= PhaseId.INVOKE_APPLICATION.getOrdinal(); p++) {
|
||||
PhaseId phaseId = (PhaseId) PhaseId.VALUES.get(p);
|
||||
PhaseId phaseId = PhaseId.VALUES.get(p);
|
||||
if (!skipPhase(context, phaseId)) {
|
||||
if (isAtLeastJsf20()) {
|
||||
context.setCurrentPhaseId(phaseId);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class Jsf2FlowFacesContext extends FlowFacesContext {
|
||||
return delegate.getContextName();
|
||||
}
|
||||
|
||||
public void addResponseCookie(String name, String value, Map properties) {
|
||||
public void addResponseCookie(String name, String value, Map<String, Object> properties) {
|
||||
delegate.addResponseCookie(name, value, properties);
|
||||
}
|
||||
|
||||
@@ -240,11 +240,11 @@ public class Jsf2FlowFacesContext extends FlowFacesContext {
|
||||
delegate.setResponseContentLength(length);
|
||||
}
|
||||
|
||||
public String encodeBookmarkableURL(String baseUrl, Map parameters) {
|
||||
public String encodeBookmarkableURL(String baseUrl, Map<String, List<String>> parameters) {
|
||||
return delegate.encodeBookmarkableURL(baseUrl, parameters);
|
||||
}
|
||||
|
||||
public String encodeRedirectURL(String baseUrl, Map parameters) {
|
||||
public String encodeRedirectURL(String baseUrl, Map<String, List<String>> parameters) {
|
||||
return delegate.encodeRedirectURL(baseUrl, parameters);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
@@ -40,11 +41,13 @@ public class Jsf2FlowViewHandler extends FlowViewHandler {
|
||||
return getDelegate().calculateCharacterEncoding(context);
|
||||
}
|
||||
|
||||
public String getBookmarkableURL(FacesContext context, String viewId, Map parameters, boolean includeViewParams) {
|
||||
public String getBookmarkableURL(FacesContext context, String viewId, Map<String, List<String>> parameters,
|
||||
boolean includeViewParams) {
|
||||
return getDelegate().getBookmarkableURL(context, viewId, parameters, includeViewParams);
|
||||
}
|
||||
|
||||
public String getRedirectURL(FacesContext context, String viewId, Map parameters, boolean includeViewParams) {
|
||||
public String getRedirectURL(FacesContext context, String viewId, Map<String, List<String>> parameters,
|
||||
boolean includeViewParams) {
|
||||
return getDelegate().getRedirectURL(context, viewId, parameters, includeViewParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class JsfManagedBeanAwareELExpressionParser extends ELExpressionParser {
|
||||
private static class RequestContextELContextFactory implements ELContextFactory {
|
||||
public ELContext getELContext(Object target) {
|
||||
RequestContext context = (RequestContext) target;
|
||||
List customResolvers = new ArrayList();
|
||||
List<ELResolver> customResolvers = new ArrayList<ELResolver>();
|
||||
customResolvers.add(new RequestContextELResolver(context));
|
||||
customResolvers.add(new FlowResourceELResolver(context));
|
||||
customResolvers.add(new ImplicitFlowVariableELResolver(context));
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
*/
|
||||
public class JsfManagedBeanPropertyAccessor implements PropertyAccessor {
|
||||
|
||||
public Class[] getSpecificTargetClasses() {
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
|
||||
MutableAttributeMap map = getScopeForBean(name);
|
||||
MutableAttributeMap<Object> map = getScopeForBean(name);
|
||||
if (map != null) {
|
||||
map.put(name, newValue);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
private MutableAttributeMap getScopeForBean(String name) {
|
||||
private MutableAttributeMap<Object> getScopeForBean(String name) {
|
||||
ExternalContext externalContext = RequestContextHolder.getRequestContext().getExternalContext();
|
||||
if (externalContext.getRequestMap().contains(name)) {
|
||||
return externalContext.getRequestMap();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
@@ -37,15 +38,15 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
*/
|
||||
public class JsfManagedBeanResolver extends ELResolver {
|
||||
|
||||
public Class getCommonPropertyType(ELContext context, Object base) {
|
||||
public Class<?> getCommonPropertyType(ELContext context, Object base) {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Iterator getFeatureDescriptors(ELContext context, Object base) {
|
||||
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class getType(ELContext context, Object base, Object property) {
|
||||
public Class<?> getType(ELContext context, Object base, Object property) {
|
||||
if (base == null) {
|
||||
Object bean = getFacesBean(property);
|
||||
if (bean != null) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.webflow.execution.RequestContext;
|
||||
/**
|
||||
* Helper class to provide information about the JSF runtime environment such as JSF version and implementation.
|
||||
*
|
||||
* @author Phil Webb
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class JsfRuntimeInformation {
|
||||
|
||||
|
||||
@@ -179,9 +179,9 @@ public class JsfViewFactory implements ViewFactory {
|
||||
if (binding != null) {
|
||||
binding.setValue(context, component);
|
||||
}
|
||||
Iterator it = component.getFacetsAndChildren();
|
||||
Iterator<UIComponent> it = component.getFacetsAndChildren();
|
||||
while (it.hasNext()) {
|
||||
UIComponent child = (UIComponent) it.next();
|
||||
UIComponent child = it.next();
|
||||
processTree(context, child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -47,29 +46,27 @@ class TreeStructureManager {
|
||||
|
||||
// children
|
||||
if (component.getChildCount() > 0) {
|
||||
List childList = component.getChildren();
|
||||
List structChildList = new ArrayList();
|
||||
List<UIComponent> childList = component.getChildren();
|
||||
List<TreeStructComponent> structChildList = new ArrayList<TreeStructComponent>();
|
||||
for (int i = 0, len = childList.size(); i < len; i++) {
|
||||
UIComponent child = (UIComponent) childList.get(i);
|
||||
UIComponent child = childList.get(i);
|
||||
if (!child.isTransient()) {
|
||||
TreeStructComponent structChild = internalBuildTreeStructureToSave(child);
|
||||
structChildList.add(structChild);
|
||||
}
|
||||
}
|
||||
TreeStructComponent[] childArray = (TreeStructComponent[]) structChildList
|
||||
.toArray(new TreeStructComponent[structChildList.size()]);
|
||||
TreeStructComponent[] childArray = structChildList.toArray(new TreeStructComponent[structChildList.size()]);
|
||||
structComp.setChildren(childArray);
|
||||
}
|
||||
|
||||
// facets
|
||||
Map facetMap = component.getFacets();
|
||||
Map<String, UIComponent> facetMap = component.getFacets();
|
||||
if (!facetMap.isEmpty()) {
|
||||
List structFacetList = new ArrayList();
|
||||
for (Iterator it = facetMap.entrySet().iterator(); it.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
UIComponent child = (UIComponent) entry.getValue();
|
||||
List<Object[]> structFacetList = new ArrayList<Object[]>();
|
||||
for (Map.Entry<String, UIComponent> entry : facetMap.entrySet()) {
|
||||
UIComponent child = entry.getValue();
|
||||
if (!child.isTransient()) {
|
||||
String facetName = (String) entry.getKey();
|
||||
String facetName = entry.getKey();
|
||||
TreeStructComponent structChild = internalBuildTreeStructureToSave(child);
|
||||
structFacetList.add(new Object[] { facetName, structChild });
|
||||
}
|
||||
@@ -103,9 +100,9 @@ class TreeStructureManager {
|
||||
// children
|
||||
TreeStructComponent[] childArray = treeStructComp.getChildren();
|
||||
if (childArray != null) {
|
||||
List childList = component.getChildren();
|
||||
for (int i = 0, len = childArray.length; i < len; i++) {
|
||||
UIComponent child = internalRestoreTreeStructure(childArray[i]);
|
||||
List<UIComponent> childList = component.getChildren();
|
||||
for (TreeStructComponent element : childArray) {
|
||||
UIComponent child = internalRestoreTreeStructure(element);
|
||||
childList.add(child);
|
||||
}
|
||||
}
|
||||
@@ -113,9 +110,9 @@ class TreeStructureManager {
|
||||
// facets
|
||||
Object[] facetArray = treeStructComp.getFacets();
|
||||
if (facetArray != null) {
|
||||
Map facetMap = component.getFacets();
|
||||
for (int i = 0, len = facetArray.length; i < len; i++) {
|
||||
Object[] tuple = (Object[]) facetArray[i];
|
||||
Map<String, UIComponent> facetMap = component.getFacets();
|
||||
for (Object element : facetArray) {
|
||||
Object[] tuple = (Object[]) element;
|
||||
String facetName = (String) tuple[0];
|
||||
TreeStructComponent structChild = (TreeStructComponent) tuple[1];
|
||||
UIComponent child = internalRestoreTreeStructure(structChild);
|
||||
|
||||
@@ -92,12 +92,11 @@ public class PortletFaceletViewHandler extends FaceletViewHandler {
|
||||
return writer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected String getResponseEncoding(FacesContext context, String originalEncoding) {
|
||||
String encoding = originalEncoding;
|
||||
|
||||
Map requestMap = context.getExternalContext().getRequestMap();
|
||||
Map sessionMap = context.getExternalContext().getSessionMap();
|
||||
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
|
||||
Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
|
||||
|
||||
// 1. check the request attribute
|
||||
if (requestMap.containsKey(FACELETS_ENCODING_KEY)) {
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.webflow.core.collection.CollectionUtils;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class InitParameterMap extends StringKeyedMapAdapter {
|
||||
public class InitParameterMap extends StringKeyedMapAdapter<String> {
|
||||
|
||||
final private PortletContext portletContext;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class InitParameterMap extends StringKeyedMapAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAttribute(String key, Object value) {
|
||||
protected void setAttribute(String key, String value) {
|
||||
throw new UnsupportedOperationException("Cannot set PortletContext InitParameter");
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class InitParameterMap extends StringKeyedMapAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return CollectionUtils.toIterator(portletContext.getInitParameterNames());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request parameters as a String array.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getParameterValues(String)
|
||||
*/
|
||||
public class MultiValueRequestParameterMap extends RequestParameterMap<String[]> {
|
||||
|
||||
public MultiValueRequestParameterMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String[] getAttribute(String key) {
|
||||
return getPortletRequest().getParameterValues(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request properties as a String array.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getProperties(String)
|
||||
*/
|
||||
public class MultiValueRequestPropertyMap extends RequestPropertyMap<String[]> {
|
||||
|
||||
public MultiValueRequestPropertyMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String[] getAttribute(String key) {
|
||||
List<String> list = Collections.list(getPortletRequest().getProperties(key));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
|
||||
private Map<String, String[]> requestParameterValuesMap;
|
||||
|
||||
private MapAdaptable sessionMap;
|
||||
private MapAdaptable<String, Object> sessionMap;
|
||||
|
||||
public PortletExternalContextImpl(PortletContext portletContext, PortletRequest portletRequest,
|
||||
PortletResponse portletResponse) {
|
||||
@@ -122,7 +122,6 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
if (applicationMap == null) {
|
||||
applicationMap = new PortletContextMap(portletContext);
|
||||
@@ -146,7 +145,6 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> getInitParameterMap() {
|
||||
if (initParameterMap == null) {
|
||||
initParameterMap = new InitParameterMap(portletContext);
|
||||
@@ -175,29 +173,22 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getRequestCookieMap() {
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> getRequestHeaderMap() {
|
||||
if (requestHeaderMap == null) {
|
||||
RequestPropertyMap map = new RequestPropertyMap(portletRequest);
|
||||
map.setUseArrayForMultiValueAttributes(Boolean.FALSE);
|
||||
requestHeaderMap = map;
|
||||
requestHeaderMap = new SingleValueRequestPropertyMap(portletRequest);
|
||||
}
|
||||
return requestHeaderMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String[]> getRequestHeaderValuesMap() {
|
||||
if (requestHeaderValuesMap == null) {
|
||||
RequestPropertyMap map = new RequestPropertyMap(portletRequest);
|
||||
map.setUseArrayForMultiValueAttributes(Boolean.TRUE);
|
||||
requestHeaderValuesMap = map;
|
||||
requestHeaderValuesMap = new MultiValueRequestPropertyMap(portletRequest);
|
||||
}
|
||||
return requestHeaderValuesMap;
|
||||
}
|
||||
@@ -208,13 +199,11 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<Locale> getRequestLocales() {
|
||||
return CollectionUtils.toIterator(portletRequest.getLocales());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getRequestMap() {
|
||||
if (requestMap == null) {
|
||||
requestMap = new PortletRequestMap(portletRequest);
|
||||
@@ -223,29 +212,22 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> getRequestParameterMap() {
|
||||
if (requestParameterMap == null) {
|
||||
RequestParameterMap map = new RequestParameterMap(portletRequest);
|
||||
map.setUseArrayForMultiValueAttributes(Boolean.FALSE);
|
||||
requestParameterMap = map;
|
||||
requestParameterMap = new SingleValueRequestParameterMap(portletRequest);
|
||||
}
|
||||
return requestParameterMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<String> getRequestParameterNames() {
|
||||
return CollectionUtils.toIterator(portletRequest.getParameterNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String[]> getRequestParameterValuesMap() {
|
||||
if (requestParameterValuesMap == null) {
|
||||
RequestParameterMap map = new RequestParameterMap(portletRequest);
|
||||
map.setUseArrayForMultiValueAttributes(Boolean.TRUE);
|
||||
requestParameterValuesMap = map;
|
||||
requestParameterValuesMap = new MultiValueRequestParameterMap(portletRequest);
|
||||
}
|
||||
return requestParameterValuesMap;
|
||||
}
|
||||
@@ -302,10 +284,9 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getSessionMap() {
|
||||
if (sessionMap == null) {
|
||||
sessionMap = new LocalAttributeMap(new PortletSessionMap(portletRequest));
|
||||
sessionMap = new LocalAttributeMap<Object>(new PortletSessionMap(portletRequest));
|
||||
}
|
||||
return sessionMap.asMap();
|
||||
}
|
||||
|
||||
@@ -141,8 +141,9 @@ public class PortletFacesContextImpl extends FacesContext {
|
||||
list.add(messages.get(i));
|
||||
}
|
||||
} else {
|
||||
if (clientId.equals(current))
|
||||
if (clientId.equals(current)) {
|
||||
list.add(messages.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.iterator();
|
||||
|
||||
@@ -15,71 +15,72 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
import org.springframework.binding.collection.StringKeyedMapAdapter;
|
||||
import org.springframework.webflow.context.portlet.PortletRequestParameterMap;
|
||||
|
||||
/**
|
||||
* Map backed by a PortletContext for accessing Portlet request parameters. Request parameters can have multiple values.
|
||||
* The {@link RequestParameterMap#setUseArrayForMultiValueAttributes(Boolean)} property allows choosing whether the map
|
||||
* will return:
|
||||
* <ul>
|
||||
* <li>String - selects the first value in case of multiple value parameters</li>
|
||||
* <li>String[] - wraps single-values parameters as array</li>
|
||||
* <li>String or String[] - depends on the values of the parameter</li>
|
||||
* </ul>
|
||||
* /** Base class for {@link Map}s allowing access to {@link PortletContext} request paramters.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @see PortletRequest#getParameter(String)
|
||||
* @see PortletRequest#getParameterValues(String)
|
||||
* @see SingleValueRequestParameterMap
|
||||
* @see MultiValueRequestParameterMap
|
||||
*/
|
||||
public class RequestParameterMap extends PortletRequestParameterMap {
|
||||
|
||||
private Boolean useArrayForMultiValueAttributes;
|
||||
public abstract class RequestParameterMap<V> extends StringKeyedMapAdapter<V> {
|
||||
|
||||
private PortletRequest portletRequest;
|
||||
|
||||
private Delegate delegate;
|
||||
|
||||
public RequestParameterMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
this.portletRequest = portletRequest;
|
||||
this.delegate = new Delegate(portletRequest);
|
||||
}
|
||||
|
||||
public void setUseArrayForMultiValueAttributes(Boolean useArrayForMultiValueAttributes) {
|
||||
this.useArrayForMultiValueAttributes = useArrayForMultiValueAttributes;
|
||||
protected final PortletRequest getPortletRequest() {
|
||||
return portletRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* This property allows choosing what kind of attributes the map will return:
|
||||
* <ol>
|
||||
* <li>String - selects the first value in case of multiple value parameters</li>
|
||||
* <li>String[] - wraps single-values parameters as array</li>
|
||||
* <li>String or String[] - depends on the values of the parameter</li>
|
||||
* </ol>
|
||||
* The above choices correspond to the following values for useArrayForMultiValueAttributes:
|
||||
* <ol>
|
||||
* <li>False</li>
|
||||
* <li>True</li>
|
||||
* <li>null</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param useArrayForMultiValueAttributes
|
||||
*/
|
||||
public Boolean useArrayForMultiValueAttributes() {
|
||||
return useArrayForMultiValueAttributes;
|
||||
protected void setAttribute(String key, V value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String key) {
|
||||
if (null == useArrayForMultiValueAttributes) {
|
||||
protected void removeAttribute(String key) {
|
||||
delegate.removeAttribute(key);
|
||||
}
|
||||
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return delegate.getAttributeNames();
|
||||
}
|
||||
|
||||
private static class Delegate extends PortletRequestParameterMap {
|
||||
|
||||
public Delegate(PortletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
public Object getAttribute(String key) {
|
||||
return super.getAttribute(key);
|
||||
} else {
|
||||
if (useArrayForMultiValueAttributes) {
|
||||
return portletRequest.getParameterValues(key);
|
||||
} else {
|
||||
return portletRequest.getParameter(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object value) {
|
||||
super.setAttribute(key, value);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
super.removeAttribute(key);
|
||||
}
|
||||
|
||||
public Iterator<String> getAttributeNames() {
|
||||
return super.getAttributeNames();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,34 +15,26 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
import org.springframework.binding.collection.StringKeyedMapAdapter;
|
||||
import org.springframework.webflow.core.collection.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Map backed by a PortletContext for accessing Portlet request properties. Request properties can have multiple values.
|
||||
* The {@link RequestPropertyMap#setUseArrayForMultiValueAttributes(Boolean)} property allows choosing whether the map
|
||||
* will return:
|
||||
* <ul>
|
||||
* <li>String - selects the first element in case of multiple values</li>
|
||||
* <li>String[] - wraps single-values attributes as array</li>
|
||||
* <li>String or String[] - depends on the values of the property</li>
|
||||
* </ul>
|
||||
* Base class for {@link Map}s allowing access to {@link PortletContext} request properties.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @see PortletRequest#getProperty(String)
|
||||
* @see PortletRequest#getProperties(String)
|
||||
* @see SingleValueRequestPropertyMap
|
||||
* @see MultiValueRequestPropertyMap
|
||||
*/
|
||||
public class RequestPropertyMap extends StringKeyedMapAdapter {
|
||||
|
||||
private Boolean useArrayForMultiValueAttributes;
|
||||
public abstract class RequestPropertyMap<V> extends StringKeyedMapAdapter<V> {
|
||||
|
||||
private final PortletRequest portletRequest;
|
||||
|
||||
@@ -50,51 +42,12 @@ public class RequestPropertyMap extends StringKeyedMapAdapter {
|
||||
this.portletRequest = portletRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* This property allows choosing what kind of attributes the map will return:
|
||||
* <ol>
|
||||
* <li>String - selects the first element in case of multiple values</li>
|
||||
* <li>String[] - wraps single-values attributes as array</li>
|
||||
* <li>String or String[] - depends on the values of the property</li>
|
||||
* </ol>
|
||||
* The above choices correspond to the following values for useArrayForMultiValueAttributes:
|
||||
* <ol>
|
||||
* <li>False</li>
|
||||
* <li>True</li>
|
||||
* <li>null</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param useArrayForMultiValueAttributes
|
||||
*/
|
||||
public void setUseArrayForMultiValueAttributes(Boolean useArrayForMultiValueAttributes) {
|
||||
this.useArrayForMultiValueAttributes = useArrayForMultiValueAttributes;
|
||||
}
|
||||
|
||||
public Boolean useArrayForMultiValueAttributes() {
|
||||
return useArrayForMultiValueAttributes;
|
||||
protected final PortletRequest getPortletRequest() {
|
||||
return portletRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String key) {
|
||||
if (null == useArrayForMultiValueAttributes) {
|
||||
List<String> list = Collections.list(portletRequest.getProperties(key));
|
||||
if (1 == list.size()) {
|
||||
return list.get(0);
|
||||
} else {
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
} else {
|
||||
if (useArrayForMultiValueAttributes) {
|
||||
List<String> list = Collections.list(portletRequest.getProperties(key));
|
||||
return list.toArray(new String[list.size()]);
|
||||
} else {
|
||||
return portletRequest.getProperty(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAttribute(String key, Object value) {
|
||||
protected void setAttribute(String key, V value) {
|
||||
throw new UnsupportedOperationException("Cannot set PortletRequest property");
|
||||
}
|
||||
|
||||
@@ -104,9 +57,7 @@ public class RequestPropertyMap extends StringKeyedMapAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Iterator<String> getAttributeNames() {
|
||||
return CollectionUtils.toIterator(portletRequest.getPropertyNames());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request parameters containing single String values.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getParameterValues(String)
|
||||
*/
|
||||
public class SingleValueRequestParameterMap extends RequestParameterMap<String> {
|
||||
|
||||
public SingleValueRequestParameterMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String getAttribute(String key) {
|
||||
return getPortletRequest().getParameter(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
/**
|
||||
* A {@link Map} for accessing to {@link PortletContext} request properties containing single String values.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @see PortletRequest#getProperties(String)
|
||||
*/
|
||||
public class SingleValueRequestPropertyMap extends RequestPropertyMap<String> {
|
||||
|
||||
public SingleValueRequestPropertyMap(PortletRequest portletRequest) {
|
||||
super(portletRequest);
|
||||
}
|
||||
|
||||
protected String getAttribute(String key) {
|
||||
return getPortletRequest().getProperty(key);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.faces.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.binding.convert.ConversionException;
|
||||
@@ -91,29 +89,25 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
|
||||
|
||||
public static class TestConversionService implements ConversionService {
|
||||
|
||||
public Object executeConversion(Object source, Class targetClass) throws ConversionException {
|
||||
public Object executeConversion(Object source, Class<?> targetClass) throws ConversionException {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public Object executeConversion(String converterId, Object source, Class targetClass) {
|
||||
public Object executeConversion(String converterId, Object source, Class<?> targetClass) {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
|
||||
public ConversionExecutor getConversionExecutor(Class<?> sourceClass, Class<?> targetClass)
|
||||
throws ConversionExecutionException {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass)
|
||||
public ConversionExecutor getConversionExecutor(String id, Class<?> sourceClass, Class<?> targetClass)
|
||||
throws ConversionExecutorNotFoundException {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public Set getConversionExecutors(Class sourceClass) {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public Class getClassForAlias(String name) throws ConversionExecutionException {
|
||||
public Class<?> getClassForAlias(String name) throws ConversionExecutionException {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ResourcesBeanDefinitionParserTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testConfigureDefaults() {
|
||||
Map map = context.getBeansOfType(HttpRequestHandlerAdapter.class);
|
||||
Map<String, ?> map = context.getBeansOfType(HttpRequestHandlerAdapter.class);
|
||||
assertEquals(1, map.values().size());
|
||||
|
||||
Object resourceHandler = context.getBean(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME);
|
||||
@@ -31,8 +31,8 @@ public class ResourcesBeanDefinitionParserTests extends TestCase {
|
||||
map = context.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
assertEquals(1, map.values().size());
|
||||
SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) map.values().iterator().next();
|
||||
assertEquals(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME, handlerMapping.getUrlMap().get(
|
||||
"/javax.faces.resource/**"));
|
||||
assertEquals(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME,
|
||||
handlerMapping.getUrlMap().get("/javax.faces.resource/**"));
|
||||
assertEquals(0, handlerMapping.getOrder());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SelectionTrackingActionListenerTests extends TestCase {
|
||||
/**
|
||||
* The list of row data objects to
|
||||
*/
|
||||
private OneSelectionTrackingListDataModel dataModel;
|
||||
private OneSelectionTrackingListDataModel<Object> dataModel;
|
||||
|
||||
/**
|
||||
* The delegate action listener that should be called
|
||||
@@ -51,11 +51,11 @@ public class SelectionTrackingActionListenerTests extends TestCase {
|
||||
public void setUp() throws Exception {
|
||||
jsfMockHelper.setUp();
|
||||
viewToTest = new UIViewRoot();
|
||||
List rows = new ArrayList();
|
||||
List<Object> rows = new ArrayList<Object>();
|
||||
rows.add(new TestRowData());
|
||||
rows.add(new TestRowData());
|
||||
rows.add(new TestRowData());
|
||||
dataModel = new OneSelectionTrackingListDataModel(rows);
|
||||
dataModel = new OneSelectionTrackingListDataModel<Object>(rows);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
||||
@@ -16,28 +16,33 @@ public class DataModelConverterTests extends TestCase {
|
||||
|
||||
Converter converter = new DataModelConverter();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testConvertListToDataModel() throws Exception {
|
||||
List sourceList = new ArrayList();
|
||||
List<Object> sourceList = new ArrayList<Object>();
|
||||
|
||||
DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, DataModel.class);
|
||||
DataModel<Object> resultModel = (DataModel<Object>) converter.convertSourceToTargetClass(sourceList,
|
||||
DataModel.class);
|
||||
|
||||
assertNotNull(resultModel);
|
||||
assertSame(sourceList, resultModel.getWrappedData());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testConvertListToListDataModel() throws Exception {
|
||||
List sourceList = new ArrayList();
|
||||
List<Object> sourceList = new ArrayList<Object>();
|
||||
|
||||
DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, ListDataModel.class);
|
||||
DataModel<Object> resultModel = (DataModel<Object>) converter.convertSourceToTargetClass(sourceList,
|
||||
ListDataModel.class);
|
||||
|
||||
assertNotNull(resultModel);
|
||||
assertSame(sourceList, resultModel.getWrappedData());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testConvertListToSerializableListDataModel() throws Exception {
|
||||
List sourceList = new ArrayList();
|
||||
List<Object> sourceList = new ArrayList<Object>();
|
||||
|
||||
DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList,
|
||||
DataModel<Object> resultModel = (DataModel<Object>) converter.convertSourceToTargetClass(sourceList,
|
||||
SerializableListDataModel.class);
|
||||
|
||||
assertNotNull(resultModel);
|
||||
@@ -45,10 +50,11 @@ public class DataModelConverterTests extends TestCase {
|
||||
assertTrue(resultModel instanceof Serializable);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testConvertListToSerializableListDataModelNullSource() throws Exception {
|
||||
List sourceList = null;
|
||||
List<Object> sourceList = null;
|
||||
|
||||
DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList,
|
||||
DataModel<Object> resultModel = (DataModel<Object>) converter.convertSourceToTargetClass(sourceList,
|
||||
SerializableListDataModel.class);
|
||||
|
||||
assertNotNull(resultModel);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class FacesConversionServiceTests extends TestCase {
|
||||
|
||||
public void testGetAbstractType() {
|
||||
ConversionExecutor executor = service.getConversionExecutor(List.class, DataModel.class);
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList<Object> list = new ArrayList<Object>();
|
||||
list.add("foo");
|
||||
executor.execute(list);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JsfViewTests extends TestCase {
|
||||
JsfView view = (JsfView) resolver.resolveViewName("intro", new Locale("EN"));
|
||||
view.setApplicationContext(new StaticWebApplicationContext());
|
||||
view.setServletContext(new MockServletContext());
|
||||
view.render(new HashMap(), new MockHttpServletRequest(), new MockHttpServletResponse());
|
||||
view.render(new HashMap<String, Object>(), new MockHttpServletRequest(), new MockHttpServletResponse());
|
||||
}
|
||||
|
||||
private class ResourceCheckingViewHandler extends MockViewHandler {
|
||||
|
||||
@@ -67,14 +67,16 @@ public class AjaxViewRootTests extends TestCase {
|
||||
|
||||
assertEquals(1, ajaxRoot.getProcessIds().length);
|
||||
assertEquals(1, ajaxRoot.getRenderIds().length);
|
||||
assertEquals(StringUtils.arrayToCommaDelimitedString(ajaxRoot.getProcessIds()), StringUtils
|
||||
.arrayToCommaDelimitedString(ajaxRoot.getRenderIds()));
|
||||
assertEquals(StringUtils.arrayToCommaDelimitedString(ajaxRoot.getProcessIds()),
|
||||
StringUtils.arrayToCommaDelimitedString(ajaxRoot.getRenderIds()));
|
||||
}
|
||||
|
||||
public void testEncodeAll_RenderIdsExpr() throws IOException {
|
||||
|
||||
jsf.externalContext().getRequestMap().put(View.RENDER_FRAGMENTS_ATTRIBUTE,
|
||||
StringUtils.delimitedListToStringArray("foo:bar,foo:baz", ",", " "));
|
||||
jsf.externalContext()
|
||||
.getRequestMap()
|
||||
.put(View.RENDER_FRAGMENTS_ATTRIBUTE,
|
||||
StringUtils.delimitedListToStringArray("foo:bar,foo:baz", ",", " "));
|
||||
|
||||
AjaxViewRoot ajaxRoot = new AjaxViewRoot(testTree);
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
|
||||
link.setId("foo");
|
||||
form.getChildren().add(link);
|
||||
|
||||
RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link)
|
||||
.get("onclick");
|
||||
RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
@@ -62,8 +61,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
|
||||
link.getChildren().add(param1);
|
||||
link.getChildren().add(param2);
|
||||
|
||||
RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link)
|
||||
.get("onclick");
|
||||
RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
@@ -84,8 +82,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
|
||||
link.setAjaxEnabled(Boolean.FALSE);
|
||||
form.getChildren().add(link);
|
||||
|
||||
RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link)
|
||||
.get("onclick");
|
||||
RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
@@ -116,8 +113,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
|
||||
link.getChildren().add(param1);
|
||||
link.getChildren().add(param2);
|
||||
|
||||
RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link)
|
||||
.get("onclick");
|
||||
RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ public class FlowActionListenerTests extends TestCase {
|
||||
|
||||
JSFMockHelper jsfMock = new JSFMockHelper();
|
||||
|
||||
RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class);
|
||||
RequestContext context = EasyMock.createMock(RequestContext.class);
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
jsfMock.setUp();
|
||||
|
||||
listener = new FlowActionListener(jsfMock.application().getActionListener());
|
||||
RequestContextHolder.setRequestContext(context);
|
||||
LocalAttributeMap flash = new LocalAttributeMap();
|
||||
LocalAttributeMap<Object> flash = new LocalAttributeMap<Object>();
|
||||
EasyMock.expect(context.getFlashScope()).andStubReturn(flash);
|
||||
EasyMock.expect(context.getCurrentState()).andStubReturn(new MockViewState());
|
||||
EasyMock.replay(new Object[] { context });
|
||||
@@ -79,7 +79,7 @@ public class FlowActionListenerTests extends TestCase {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Class getType(FacesContext context) throws MethodNotFoundException {
|
||||
public Class<?> getType(FacesContext context) throws MethodNotFoundException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ public class FlowFacesContextTests extends TestCase {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR"));
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getMessages(null);
|
||||
Iterator<FacesMessage> i = facesContext.getMessages(null);
|
||||
while (i.hasNext()) {
|
||||
FacesMessage message = (FacesMessage) i.next();
|
||||
FacesMessage message = i.next();
|
||||
assertNotNull(message);
|
||||
iterationCount++;
|
||||
}
|
||||
@@ -91,9 +91,9 @@ public class FlowFacesContextTests extends TestCase {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR"));
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getMessages();
|
||||
Iterator<FacesMessage> i = facesContext.getMessages();
|
||||
while (i.hasNext()) {
|
||||
FacesMessage message = (FacesMessage) i.next();
|
||||
FacesMessage message = i.next();
|
||||
assertNotNull(message);
|
||||
iterationCount++;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getMessages();
|
||||
Iterator<FacesMessage> i = facesContext.getMessages();
|
||||
while (i.hasNext()) {
|
||||
assertNotNull(i.next());
|
||||
iterationCount++;
|
||||
@@ -139,7 +139,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
facesContext.addMessage("TESTID", new FacesMessage("summary1"));
|
||||
FacesMessage soruceMessage = (FacesMessage) facesContext.getMessages("TESTID").next();
|
||||
FacesMessage soruceMessage = facesContext.getMessages("TESTID").next();
|
||||
soruceMessage.setSummary("summary2");
|
||||
|
||||
// check that message sticks around even when the facesContext has been torn down and re-created during the
|
||||
@@ -147,7 +147,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
FacesContext newFacesContext = new FlowFacesContext(requestContext, jsf.facesContext());
|
||||
assertSame(FacesContext.getCurrentInstance(), newFacesContext);
|
||||
|
||||
FacesMessage gotMessage = (FacesMessage) newFacesContext.getMessages("TESTID").next();
|
||||
FacesMessage gotMessage = newFacesContext.getMessages("TESTID").next();
|
||||
assertEquals("summary2", gotMessage.getSummary());
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getMessages("componentId");
|
||||
Iterator<FacesMessage> i = facesContext.getMessages("componentId");
|
||||
while (i.hasNext()) {
|
||||
FacesMessage message = (FacesMessage) i.next();
|
||||
FacesMessage message = i.next();
|
||||
assertNotNull(message);
|
||||
assertEquals("componentId_summary" + (iterationCount + 1), message.getSummary());
|
||||
assertEquals("componentId_detail" + (iterationCount + 1), message.getDetail());
|
||||
@@ -174,9 +174,9 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getMessages("userMessage");
|
||||
Iterator<FacesMessage> i = facesContext.getMessages("userMessage");
|
||||
while (i.hasNext()) {
|
||||
FacesMessage message = (FacesMessage) i.next();
|
||||
FacesMessage message = i.next();
|
||||
assertNotNull(message);
|
||||
assertEquals("userMessage", message.getSummary());
|
||||
assertEquals("userMessage", message.getDetail());
|
||||
@@ -190,7 +190,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.expect(requestContext.getMessageContext()).andStubReturn(messageContext);
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
Iterator i = facesContext.getMessages("unknown");
|
||||
Iterator<FacesMessage> i = facesContext.getMessages("unknown");
|
||||
assertFalse(i.hasNext());
|
||||
}
|
||||
|
||||
@@ -199,15 +199,15 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.expect(requestContext.getMessageContext()).andStubReturn(messageContext);
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
List expectedOrderedIds = new ArrayList();
|
||||
List<String> expectedOrderedIds = new ArrayList<String>();
|
||||
expectedOrderedIds.add(null);
|
||||
expectedOrderedIds.add("componentId");
|
||||
expectedOrderedIds.add("userMessage");
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator i = facesContext.getClientIdsWithMessages();
|
||||
Iterator<String> i = facesContext.getClientIdsWithMessages();
|
||||
while (i.hasNext()) {
|
||||
String clientId = (String) i.next();
|
||||
String clientId = i.next();
|
||||
assertEquals("Client id not expected", expectedOrderedIds.get(iterationCount), clientId);
|
||||
iterationCount++;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
EasyMock.replay(new Object[] { requestContext });
|
||||
|
||||
facesContext.addMessage("TESTID", new FacesMessage("summary1"));
|
||||
FacesMessage sourceMessage = (FacesMessage) facesContext.getMessages("TESTID").next();
|
||||
FacesMessage sourceMessage = facesContext.getMessages("TESTID").next();
|
||||
sourceMessage.setSummary("summary2");
|
||||
sourceMessage.setSeverity(FacesMessage.SEVERITY_FATAL);
|
||||
|
||||
@@ -244,7 +244,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
|
||||
FacesContext newFacesContext = new FlowFacesContext(requestContext, jsf.facesContext());
|
||||
assertSame(FacesContext.getCurrentInstance(), newFacesContext);
|
||||
FacesMessage gotMessage = (FacesMessage) newFacesContext.getMessages("TESTID").next();
|
||||
FacesMessage gotMessage = newFacesContext.getMessages("TESTID").next();
|
||||
assertEquals("summary2", gotMessage.getSummary());
|
||||
assertEquals(FacesMessage.SEVERITY_FATAL, gotMessage.getSeverity());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.springframework.webflow.test.MockRequestContext;
|
||||
|
||||
public class FlowPartialViewContextTests extends TestCase {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testReturnFragmentIds() throws Exception {
|
||||
String[] fragmentIds = new String[] { "foo", "bar" };
|
||||
|
||||
@@ -47,7 +46,6 @@ public class FlowPartialViewContextTests extends TestCase {
|
||||
assertEquals(renderIds, context.getRenderIds());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testReturnFragmentIdsMutable() throws Exception {
|
||||
String[] fragmentIds = new String[] { "foo", "bar" };
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FlowViewResponseStateManagerTests extends TestCase {
|
||||
|
||||
public void testWriteFlowSerializedView() throws Exception {
|
||||
EasyMock.expect(flowExecutionContext.getKey()).andReturn(new MockFlowExecutionKey("e1s1"));
|
||||
LocalAttributeMap viewMap = new LocalAttributeMap();
|
||||
LocalAttributeMap<Object> viewMap = new LocalAttributeMap<Object>();
|
||||
EasyMock.expect(requestContext.getViewScope()).andStubReturn(viewMap);
|
||||
EasyMock.expect(requestContext.getFlowExecutionContext()).andReturn(flowExecutionContext);
|
||||
EasyMock.replay(requestContext, flowExecutionContext);
|
||||
@@ -57,7 +57,7 @@ public class FlowViewResponseStateManagerTests extends TestCase {
|
||||
Object componentState = new Object();
|
||||
FlowSerializedView flowSerializedView = new FlowSerializedView("viewId", treeStructure, componentState);
|
||||
|
||||
LocalAttributeMap viewMap = new LocalAttributeMap();
|
||||
LocalAttributeMap<Object> viewMap = new LocalAttributeMap<Object>();
|
||||
viewMap.put(FlowViewStateManager.SERIALIZED_VIEW_STATE, flowSerializedView);
|
||||
EasyMock.expect(requestContext.getViewScope()).andStubReturn(viewMap);
|
||||
EasyMock.replay(requestContext);
|
||||
|
||||
@@ -7,7 +7,7 @@ public class JSFManagedBean {
|
||||
|
||||
String prop1;
|
||||
JSFModel model;
|
||||
List values = new ArrayList();
|
||||
List<String> values = new ArrayList<String>();
|
||||
|
||||
public JSFModel getModel() {
|
||||
return model;
|
||||
@@ -29,7 +29,7 @@ public class JSFManagedBean {
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
public List getValues() {
|
||||
public List<String> getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JsfFinalResponseActionTests extends TestCase {
|
||||
|
||||
private JSFMockHelper jsfMock = new JSFMockHelper();
|
||||
|
||||
private RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class);
|
||||
private RequestContext context = EasyMock.createMock(RequestContext.class);
|
||||
|
||||
private ViewHandler viewHandler = new NoRenderViewHandler();
|
||||
|
||||
@@ -74,9 +74,10 @@ public class JsfFinalResponseActionTests extends TestCase {
|
||||
ext.setNativeRequest(new MockHttpServletRequest());
|
||||
ext.setNativeResponse(new MockHttpServletResponse());
|
||||
EasyMock.expect(context.getExternalContext()).andStubReturn(ext);
|
||||
LocalAttributeMap requestMap = new LocalAttributeMap();
|
||||
LocalAttributeMap<Object> requestMap = new LocalAttributeMap<Object>();
|
||||
EasyMock.expect(context.getFlashScope()).andStubReturn(requestMap);
|
||||
EasyMock.expect(context.getRequestParameters()).andStubReturn(new LocalParameterMap(new HashMap()));
|
||||
EasyMock.expect(context.getRequestParameters()).andStubReturn(
|
||||
new LocalParameterMap(new HashMap<String, Object>()));
|
||||
}
|
||||
|
||||
public void testRender() throws Exception {
|
||||
@@ -116,7 +117,7 @@ public class JsfFinalResponseActionTests extends TestCase {
|
||||
|
||||
private class TrackingPhaseListener implements PhaseListener {
|
||||
|
||||
private List phaseCallbacks = new ArrayList();
|
||||
private List<String> phaseCallbacks = new ArrayList<String>();
|
||||
|
||||
public void afterPhase(PhaseEvent event) {
|
||||
String phaseCallback = "AFTER_" + event.getPhaseId();
|
||||
@@ -135,11 +136,6 @@ public class JsfFinalResponseActionTests extends TestCase {
|
||||
public PhaseId getPhaseId() {
|
||||
return PhaseId.ANY_PHASE;
|
||||
}
|
||||
|
||||
public List getPhaseCallbacks() {
|
||||
return phaseCallbacks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class NoRenderViewHandler extends MockViewHandler {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class JsfFlowHandlerAdapterTests extends TestCase {
|
||||
throw new UnsupportedOperationException("Not expected");
|
||||
}
|
||||
|
||||
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context)
|
||||
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap<?> input, ExternalContext context)
|
||||
throws FlowException {
|
||||
throw new UnsupportedOperationException("Not expected");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase {
|
||||
public void testCanWrite() throws Exception {
|
||||
assertFalse(accessor.canWrite(null, null, "myJsfBean"));
|
||||
|
||||
MutableAttributeMap map = requestContext.getExternalContext().getRequestMap();
|
||||
MutableAttributeMap<Object> map = requestContext.getExternalContext().getRequestMap();
|
||||
map.put("myJsfBean", new Object());
|
||||
assertTrue(accessor.canWrite(null, null, "myJsfBean"));
|
||||
map.clear();
|
||||
@@ -73,7 +73,7 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase {
|
||||
Object jsfBean1 = new Object();
|
||||
Object jsfBean2 = new Object();
|
||||
|
||||
MutableAttributeMap map = requestContext.getExternalContext().getRequestMap();
|
||||
MutableAttributeMap<Object> map = requestContext.getExternalContext().getRequestMap();
|
||||
accessor.write(null, null, "myJsfBean", jsfBean1);
|
||||
assertNull("Write occurs only if bean is present in the map", map.get("myJsfBean"));
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
|
||||
public class JsfUtilsTests extends TestCase {
|
||||
|
||||
public void testBeforeListenersCalledInForwardOrder() throws Exception {
|
||||
List list = new ArrayList();
|
||||
List<OrderVerifyingPhaseListener> list = new ArrayList<OrderVerifyingPhaseListener>();
|
||||
MockLifecycle lifecycle = new MockLifecycle();
|
||||
PhaseListener listener1 = new OrderVerifyingPhaseListener(null, list);
|
||||
lifecycle.addPhaseListener(listener1);
|
||||
@@ -30,7 +30,7 @@ public class JsfUtilsTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testAfterListenersCalledInReverseOrder() throws Exception {
|
||||
List list = new ArrayList();
|
||||
List<OrderVerifyingPhaseListener> list = new ArrayList<OrderVerifyingPhaseListener>();
|
||||
MockLifecycle lifecycle = new MockLifecycle();
|
||||
PhaseListener listener1 = new OrderVerifyingPhaseListener(list, null);
|
||||
lifecycle.addPhaseListener(listener1);
|
||||
@@ -46,10 +46,11 @@ public class JsfUtilsTests extends TestCase {
|
||||
|
||||
private class OrderVerifyingPhaseListener implements PhaseListener {
|
||||
|
||||
private List afterPhaseList;
|
||||
private List beforePhaseList;
|
||||
private List<OrderVerifyingPhaseListener> afterPhaseList;
|
||||
private List<OrderVerifyingPhaseListener> beforePhaseList;
|
||||
|
||||
public OrderVerifyingPhaseListener(List afterPhaseList, List beforePhaseList) {
|
||||
public OrderVerifyingPhaseListener(List<OrderVerifyingPhaseListener> afterPhaseList,
|
||||
List<OrderVerifyingPhaseListener> beforePhaseList) {
|
||||
this.afterPhaseList = afterPhaseList;
|
||||
this.beforePhaseList = beforePhaseList;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
|
||||
private RequestContext context = EasyMock.createMock(RequestContext.class);
|
||||
|
||||
private LocalAttributeMap flashMap = new LocalAttributeMap();
|
||||
private LocalAttributeMap<Object> flashMap = new LocalAttributeMap<Object>();
|
||||
|
||||
private ViewHandler viewHandler = new MockViewHandler();
|
||||
|
||||
@@ -80,7 +80,8 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
RequestContextHolder.setRequestContext(context);
|
||||
EasyMock.expect(context.getFlashScope()).andStubReturn(flashMap);
|
||||
EasyMock.expect(context.getExternalContext()).andStubReturn(extContext);
|
||||
EasyMock.expect(context.getRequestParameters()).andStubReturn(new LocalParameterMap(new HashMap()));
|
||||
EasyMock.expect(context.getRequestParameters()).andStubReturn(
|
||||
new LocalParameterMap(new HashMap<String, Object>()));
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@@ -299,7 +300,7 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
|
||||
private class TrackingPhaseListener implements PhaseListener {
|
||||
|
||||
private List phaseCallbacks = new ArrayList();
|
||||
private List<String> phaseCallbacks = new ArrayList<String>();
|
||||
|
||||
public void afterPhase(PhaseEvent event) {
|
||||
String phaseCallback = "AFTER_" + event.getPhaseId();
|
||||
@@ -318,11 +319,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
public PhaseId getPhaseId() {
|
||||
return PhaseId.ANY_PHASE;
|
||||
}
|
||||
|
||||
public List getPhaseCallbacks() {
|
||||
return phaseCallbacks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class NormalViewState implements StateDefinition {
|
||||
@@ -339,7 +335,7 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
public MutableAttributeMap getAttributes() {
|
||||
public MutableAttributeMap<Object> getAttributes() {
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,12 @@ public class JsfViewTests extends TestCase {
|
||||
|
||||
private String event = "foo";
|
||||
|
||||
private RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class);
|
||||
private FlowExecutionContext flowExecutionContext = (FlowExecutionContext) EasyMock
|
||||
.createMock(FlowExecutionContext.class);
|
||||
private MutableAttributeMap flashScope = (MutableAttributeMap) EasyMock.createMock(MutableAttributeMap.class);
|
||||
private MutableAttributeMap flowMap = (MutableAttributeMap) EasyMock.createMock(MutableAttributeMap.class);
|
||||
private RequestContext context = EasyMock.createMock(RequestContext.class);
|
||||
private FlowExecutionContext flowExecutionContext = EasyMock.createMock(FlowExecutionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
private MutableAttributeMap<Object> flashScope = EasyMock.createMock(MutableAttributeMap.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
private MutableAttributeMap<Object> flowMap = EasyMock.createMock(MutableAttributeMap.class);
|
||||
|
||||
private FlowExecutionKey key = new FlowExecutionKey() {
|
||||
|
||||
|
||||
@@ -115,41 +115,41 @@ public class MockApplication extends Application {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getComponentTypes() {
|
||||
public Iterator<String> getComponentTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addConverter(String converterId, String converterClass) {
|
||||
}
|
||||
|
||||
public void addConverter(Class targetClass, String converterClass) {
|
||||
public void addConverter(Class<?> targetClass, String converterClass) {
|
||||
}
|
||||
|
||||
public Converter createConverter(String converterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Converter createConverter(Class targetClass) {
|
||||
public Converter createConverter(Class<?> targetClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getConverterIds() {
|
||||
public Iterator<String> getConverterIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getConverterTypes() {
|
||||
public Iterator<Class<?>> getConverterTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException {
|
||||
public MethodBinding createMethodBinding(String ref, Class<?>[] params) throws ReferenceSyntaxException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getSupportedLocales() {
|
||||
public Iterator<Locale> getSupportedLocales() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSupportedLocales(Collection locales) {
|
||||
public void setSupportedLocales(Collection<Locale> locales) {
|
||||
}
|
||||
|
||||
public void addValidator(String validatorId, String validatorClass) {
|
||||
@@ -159,7 +159,7 @@ public class MockApplication extends Application {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getValidatorIds() {
|
||||
public Iterator<String> getValidatorIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MockBaseFacesContext extends MockFacesContext20 {
|
||||
super(externalContext, lifecycle);
|
||||
}
|
||||
|
||||
public Map getAttributes() {
|
||||
public Map<Object, Object> getAttributes() {
|
||||
return super.getAttributes();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MockFacesContext extends FacesContext {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public Iterator getClientIdsWithMessages() {
|
||||
public Iterator<String> getClientIdsWithMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ public class MockFacesContext extends FacesContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getMessages() {
|
||||
public Iterator<FacesMessage> getMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getMessages(String arg0) {
|
||||
public Iterator<FacesMessage> getMessages(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ import javax.faces.context.ExternalContext;
|
||||
|
||||
public class MockJsfExternalContext extends ExternalContext {
|
||||
|
||||
private Map applicationMap = new HashMap();
|
||||
private Map<String, Object> applicationMap = new HashMap<String, Object>();
|
||||
|
||||
private Map sessionMap = new HashMap();
|
||||
private Map<String, Object> sessionMap = new HashMap<String, Object>();
|
||||
|
||||
private Map requestMap = new HashMap();
|
||||
private Map<String, Object> requestMap = new HashMap<String, Object>();
|
||||
|
||||
private Map requestParameterMap = Collections.EMPTY_MAP;
|
||||
private Map<String, String> requestParameterMap = Collections.emptyMap();
|
||||
|
||||
public void dispatch(String arg0) throws IOException {
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getApplicationMap() {
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
return applicationMap;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getInitParameterMap() {
|
||||
public Map<String, Object> getInitParameterMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -87,15 +87,15 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestCookieMap() {
|
||||
public Map<String, Object> getRequestCookieMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestHeaderMap() {
|
||||
public Map<String, String> getRequestHeaderMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestHeaderValuesMap() {
|
||||
public Map<String, String[]> getRequestHeaderValuesMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getRequestLocales() {
|
||||
public Iterator<Locale> getRequestLocales() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestMap() {
|
||||
public Map<String, Object> getRequestMap() {
|
||||
return requestMap;
|
||||
}
|
||||
|
||||
@@ -115,11 +115,11 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
* Set the request map for this external context.
|
||||
* @param requestMap The requestMap to set.
|
||||
*/
|
||||
public void setRequestMap(Map requestMap) {
|
||||
public void setRequestMap(Map<String, Object> requestMap) {
|
||||
this.requestMap = requestMap;
|
||||
}
|
||||
|
||||
public Map getRequestParameterMap() {
|
||||
public Map<String, String> getRequestParameterMap() {
|
||||
return requestParameterMap;
|
||||
}
|
||||
|
||||
@@ -127,15 +127,15 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
* Set the request parameter map for this external context.
|
||||
* @param requestParameterMap the request parameter map to set.
|
||||
*/
|
||||
public void setRequestParameterMap(Map requestParameterMap) {
|
||||
public void setRequestParameterMap(Map<String, String> requestParameterMap) {
|
||||
this.requestParameterMap = requestParameterMap;
|
||||
}
|
||||
|
||||
public Iterator getRequestParameterNames() {
|
||||
public Iterator<String> getRequestParameterNames() {
|
||||
return requestParameterMap.keySet().iterator();
|
||||
}
|
||||
|
||||
public Map getRequestParameterValuesMap() {
|
||||
public Map<String, String[]> getRequestParameterValuesMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set getResourcePaths(String arg0) {
|
||||
public Set<String> getResourcePaths(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getSessionMap() {
|
||||
public Map<String, Object> getSessionMap() {
|
||||
return sessionMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,27 +4,16 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class RequestParameterMapTests extends TestCase {
|
||||
public class MultiValueRequestParameterMapTests extends TestCase {
|
||||
|
||||
private RequestParameterMap requestMap;
|
||||
private MultiValueRequestParameterMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
request = new MockPortletRequest();
|
||||
requestMap = new RequestParameterMap(request);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
request = null;
|
||||
requestMap = null;
|
||||
}
|
||||
|
||||
public void testSingleValueParameter() throws Exception {
|
||||
request.setParameter("key", "value");
|
||||
assertEquals("value", requestMap.getAttribute("key"));
|
||||
requestMap = new MultiValueRequestParameterMap(request);
|
||||
}
|
||||
|
||||
public void testMultiValueParameter() throws Exception {
|
||||
@@ -39,19 +28,10 @@ public class RequestParameterMapTests extends TestCase {
|
||||
|
||||
public void testSingleValueParameterAsArray() throws Exception {
|
||||
request.setParameter("key", "value");
|
||||
requestMap.setUseArrayForMultiValueAttributes(Boolean.TRUE);
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertTrue(actual.getClass().isArray());
|
||||
assertEquals(1, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
}
|
||||
|
||||
public void testMultiValueParameterAsString() throws Exception {
|
||||
request.setParameter("key", "value");
|
||||
request.addParameter("key", "value2");
|
||||
requestMap.setUseArrayForMultiValueAttributes(Boolean.FALSE);
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,34 +4,22 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class RequestPropertyMapTests extends TestCase {
|
||||
public class MultiValueRequestPropertyMapTest extends TestCase {
|
||||
|
||||
private RequestPropertyMap requestMap;
|
||||
private MultiValueRequestPropertyMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
request = new MockPortletRequest();
|
||||
requestMap = new RequestPropertyMap(request);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
request = null;
|
||||
requestMap = null;
|
||||
}
|
||||
|
||||
public void testSingleValueProperty() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
assertEquals("value", requestMap.getAttribute("key"));
|
||||
requestMap = new MultiValueRequestPropertyMap(request);
|
||||
}
|
||||
|
||||
public void testMultiValueProperty() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
request.addProperty("key", "value2");
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertTrue(actual.getClass().isArray());
|
||||
assertEquals(2, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
assertEquals("value2", ((String[]) actual)[1]);
|
||||
@@ -39,18 +27,8 @@ public class RequestPropertyMapTests extends TestCase {
|
||||
|
||||
public void testSingleValuePropertyAsArray() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
requestMap.setUseArrayForMultiValueAttributes(Boolean.TRUE);
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertTrue(actual.getClass().isArray());
|
||||
assertEquals(1, ((String[]) actual).length);
|
||||
assertEquals("value", ((String[]) actual)[0]);
|
||||
}
|
||||
|
||||
public void testMultiValuePropertyAsString() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
request.addProperty("key", "value2");
|
||||
requestMap.setUseArrayForMultiValueAttributes(Boolean.FALSE);
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class SingleValueRequestParameterMapTests extends TestCase {
|
||||
|
||||
private SingleValueRequestParameterMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
request = new MockPortletRequest();
|
||||
requestMap = new SingleValueRequestParameterMap(request);
|
||||
}
|
||||
|
||||
public void testSingleValueParameter() throws Exception {
|
||||
request.setParameter("key", "value");
|
||||
assertEquals("value", requestMap.getAttribute("key"));
|
||||
}
|
||||
|
||||
public void testMultiValueParameterAsString() throws Exception {
|
||||
request.setParameter("key", "value");
|
||||
request.addParameter("key", "value2");
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.springframework.faces.webflow.context.portlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||
|
||||
public class SingleValueRequestPropertyMapTest extends TestCase {
|
||||
|
||||
private SingleValueRequestPropertyMap requestMap;
|
||||
|
||||
private MockPortletRequest request;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
request = new MockPortletRequest();
|
||||
requestMap = new SingleValueRequestPropertyMap(request);
|
||||
}
|
||||
|
||||
public void testSingleValueProperty() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
assertEquals("value", requestMap.getAttribute("key"));
|
||||
}
|
||||
|
||||
public void testMultiValuePropertyAsString() throws Exception {
|
||||
request.setProperty("key", "value");
|
||||
request.addProperty("key", "value2");
|
||||
Object actual = requestMap.getAttribute("key");
|
||||
assertEquals("value", actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user