You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2010/01/05 12:50:30 UTC
svn commit: r896009 [2/30] - in /myfaces/trinidad/branches/2.0.1-branch: ./
src/site/xdoc/devguide/ trinidad-api/
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/ t...
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBeanImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBeanImpl.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBeanImpl.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBeanImpl.java Tue Jan 5 11:48:54 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,20 +22,25 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.el.ValueExpression;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHolder;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
-
-
import org.apache.myfaces.trinidad.bean.util.FlaggedPropertyMap;
+import org.apache.myfaces.trinidad.bean.util.StateUtils;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+
/**
* Base implementation of FacesBean.
*
@@ -72,8 +77,6 @@
return null;
}
-
-
/**
* {@inheritDoc}
*/
@@ -87,7 +90,6 @@
return key.getSupportsBinding() ? getValueExpression(key) : null;
}
-
// TODO Need *good* way of hooking property-sets; it's
// currently not called from state restoring, so really, it shouldn't
// be used as a hook, but EditableValueBase currently
@@ -113,7 +115,7 @@
if (map == null)
return null;
- return (ValueExpression) map.get(key);
+ return (ValueExpression) map.get(key);
}
final public void setValueExpression(PropertyKey key,
@@ -139,7 +141,7 @@
}
}
-
+
@SuppressWarnings("deprecation")
final public ValueBinding getValueBinding(PropertyKey key)
{
@@ -160,7 +162,7 @@
final public void setValueBinding(PropertyKey key, ValueBinding binding)
{
ValueExpression ve;
-
+
if (binding == null)
{
ve = null;
@@ -173,6 +175,50 @@
setValueExpression(key, ve);
}
+ final public void addClientBehavior(
+ String eventName,
+ ClientBehavior behavior)
+ {
+ if (_behaviors != null)
+ {
+ if (_behaviors.initialStateMarked())
+ {
+ // Resest the state of the behaviors so that their full state is saved when the
+ // behaviors of this component have been changed
+ _behaviors.clearInitialState();
+ }
+ }
+ else
+ {
+ _behaviors = new BehaviorMap();
+ _behaviorsReadOnly = null;
+ }
+
+ List<ClientBehavior> list = _behaviors.get(eventName);
+ if (list == null)
+ {
+ // Use a small number here as it will not be likely to have many behaviors for a component
+ // per event (probably 1)
+ list = new ArrayList<ClientBehavior>(5);
+ _behaviors.put(eventName, list);
+ }
+ list.add(behavior);
+ }
+
+ public Map<String, List<ClientBehavior>> getClientBehaviors()
+ {
+ if (_behaviors == null)
+ {
+ // never return null, per the spec.
+ return Collections.emptyMap();
+ }
+
+ if (_behaviorsReadOnly == null)
+ {
+ _behaviorsReadOnly = Collections.unmodifiableMap(_behaviors);
+ }
+ return _behaviorsReadOnly;
+ }
@SuppressWarnings("unchecked")
final public void addEntry(PropertyKey listKey, Object value)
@@ -318,7 +364,6 @@
return _expressions.keySet();
}
-
public void markInitialState()
{
_initialStateMarked = true;
@@ -328,6 +373,28 @@
if (_expressions != null)
_expressions.markInitialState();
+
+ if (_behaviors != null)
+ _behaviors.markInitialState();
+ }
+
+ public void clearInitialState()
+ {
+ _initialStateMarked = false;
+
+ if (_properties != null)
+ _properties.clearInitialState();
+
+ if (_expressions != null)
+ _expressions.clearInitialState();
+
+ if (_behaviors != null)
+ _behaviors.clearInitialState();
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _initialStateMarked;
}
public void restoreState(FacesContext context, Object state)
@@ -340,7 +407,20 @@
if (state instanceof Object[])
{
Object[] asArray = (Object[]) state;
- if (asArray.length == 2)
+ if (asArray.length == 3)
+ {
+ Object propertyState = asArray[0];
+ Object bindingsState = asArray[1];
+ Object behaviorState = asArray[2];
+ _getPropertyMap().restoreState(context, getType(), propertyState);
+ if (bindingsState != null)
+ {
+ _getExpressionsMap(true).restoreState(context, getType(), bindingsState);
+ }
+ _getBehaviors(true).restoreState(context, behaviorState);
+ return;
+ }
+ else if (asArray.length == 2)
{
Object propertyState = asArray[0];
Object bindingsState = asArray[1];
@@ -366,7 +446,6 @@
_LOG.finer("Saving state of " + this);
}
-
Object propertyState = (_properties == null)
? null
: _properties.saveState(context);
@@ -374,9 +453,15 @@
? null
: _expressions.saveState(context);
+ Object behaviorState = _behaviors == null ? null : _behaviors.saveState(context);
+
+ if (behaviorState != null)
+ {
+ return new Object[] { propertyState, bindingsState, behaviorState };
+ }
if (bindingsState != null)
{
- return new Object[]{propertyState, bindingsState};
+ return new Object[] { propertyState, bindingsState };
}
if (propertyState == null)
@@ -465,7 +550,6 @@
return (fromKey.isList() == toKey.isList());
}
-
private PropertyMap _getPropertyMap()
{
if (_properties == null)
@@ -474,6 +558,17 @@
return _properties;
}
+ private BehaviorMap _getBehaviors(
+ boolean create)
+ {
+ if (_behaviors == null && create)
+ {
+ _behaviors = new BehaviorMap();
+ }
+
+ return _behaviors;
+ }
+
private PropertyMap _getExpressionsMap(boolean createIfNew)
{
if (_expressions == null)
@@ -487,7 +582,6 @@
return _expressions;
}
-
static private void _checkListKey(PropertyKey listKey)
throws IllegalArgumentException
{
@@ -504,9 +598,172 @@
"KEY_IS_LIST_KEY", key));
}
- private PropertyMap _properties;
- private PropertyMap _expressions;
- private transient boolean _initialStateMarked;
+ private static class BehaviorMap
+ extends HashMap<String, List<ClientBehavior>>
+ implements PartialStateHolder
+ {
+ BehaviorMap()
+ {
+ // We do not expect many event types to be present on the component and we will assume 5
+ // to avoid the overhead of actually checking the number by calling the component method
+ this(5);
+ }
+
+ BehaviorMap(int initialCapacity)
+ {
+ super(initialCapacity, 1.0f);
+ }
+
+ public void markInitialState()
+ {
+ for (Map.Entry<String, List<ClientBehavior>> e : this.entrySet())
+ {
+ for (ClientBehavior behavior : e.getValue())
+ {
+ if (behavior instanceof PartialStateHolder)
+ {
+ ((PartialStateHolder)behavior).markInitialState();
+ }
+ }
+ }
+ _initialStateMarked = true;
+ }
+
+ public void clearInitialState()
+ {
+ _initialStateMarked = false;
+ for (Map.Entry<String, List<ClientBehavior>> e : this.entrySet())
+ {
+ for (ClientBehavior behavior : e.getValue())
+ {
+ if (behavior instanceof PartialStateHolder)
+ {
+ ((PartialStateHolder)behavior).clearInitialState();
+ }
+ }
+ }
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _initialStateMarked;
+ }
+
+ public Object saveState(
+ FacesContext facesContext)
+ {
+ Map<String, Object[]> state = new HashMap<String, Object[]>(this.size());
+ for (Map.Entry<String, List<ClientBehavior>> e : this.entrySet())
+ {
+ List<ClientBehavior> l = e.getValue();
+ Object[] entryState = new Object[l.size()];
+ boolean stateWasSaved = false;
+ for (int i = 0, size = entryState.length; i < size; ++i)
+ {
+ ClientBehavior behavior = l.get(i);
+ if (_initialStateMarked)
+ {
+ // JSF 2 state saving, only save the behavior's state if it is a state holder,
+ // otherwise the re-application of the template will handle the re-creation of the
+ // client behavior in the correct state
+ if (behavior instanceof StateHolder)
+ {
+ entryState[i] = ((StateHolder)behavior).saveState(facesContext);
+ }
+ }
+ else
+ {
+ // Use JSF <= 1.2 state saving method as the initial state was not marked
+ entryState[i] = StateUtils.saveStateHolder(facesContext, behavior);
+ }
+
+ stateWasSaved &= (entryState[i] != null);
+ }
+
+ if (stateWasSaved)
+ {
+ state.put(e.getKey(), entryState);
+ }
+ }
+ return state.isEmpty() ? null : state;
+ }
+
+ public void restoreState(
+ FacesContext facesContext,
+ Object state)
+ {
+ @SuppressWarnings("unchecked")
+ Map<String, Object[]> savedState = (Map<String, Object[]>) state;
+
+ if (_initialStateMarked)
+ {
+ // In JSF 2 state saving, we only need to super impose the state onto the existing
+ // client behavior list of the current map as the behaviors will already be restored in
+ // the same order that they were in the previous request (if not there is an application
+ // bug).
+ for (Map.Entry<String, Object[]> e : savedState.entrySet())
+ {
+ // Assume that the behaviors were correctly re-attached to the component and we only
+ // need to restore the state onto the objects. The order must be maintained.
+ List<ClientBehavior> behaviors = get(e.getKey());
+ Object[] entryState = e.getValue();
+ for (int i = 0, size = entryState.length; i < size; ++i)
+ {
+ if (entryState[i] != null)
+ {
+ ClientBehavior behavior = behaviors.get(i);
+ if (behavior instanceof StateHolder)
+ {
+ ((StateHolder)behavior).restoreState(facesContext, entryState[i]);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // For JSF <= 1.2 style state saving, we should ensure that we are empty and then
+ // re-hydrate the behaviors directly from the state
+ this.clear();
+
+ for (Map.Entry<String, Object[]> e : savedState.entrySet())
+ {
+ Object[] entryState = e.getValue();
+ // Assume the list is not going to grow in this request, so only allocate the size
+ // of the list from the previous request
+ List<ClientBehavior> list = new ArrayList<ClientBehavior>(entryState.length);
+ for (int i = 0, size = entryState.length; i < size; ++i)
+ {
+ list.add((ClientBehavior)StateUtils.restoreStateHolder(facesContext, entryState[i]));
+ }
+
+ this.put(e.getKey(), list);
+ }
+ }
+ }
+
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+
+ public void setTransient(
+ boolean newTransientValue)
+ {
+ _transient = newTransientValue;
+ }
+
+ private boolean _transient;
+ private boolean _initialStateMarked;
+ }
+
+ private PropertyMap _properties;
+ private PropertyMap _expressions;
+ private BehaviorMap _behaviors;
+
+ private transient boolean _initialStateMarked;
+ private transient Map<String, List<ClientBehavior>> _behaviorsReadOnly;
- static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(FacesBeanImpl.class);
+ static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(
+ FacesBeanImpl.class);
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyMap.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyMap.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyMap.java Tue Jan 5 11:48:54 2010
@@ -27,6 +27,16 @@
public interface PropertyMap extends Map<PropertyKey,Object>
{
public void markInitialState();
+
+ /**
+ * @return true if delta state changes are being tracked, otherwise false
+ */
+ public boolean initialStateMarked();
+
+ /**
+ * Reset to a non-delta tracking state.
+ */
+ public void clearInitialState();
public Object saveState(FacesContext context);
public void restoreState(FacesContext context, FacesBean.Type type, Object state);
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/FlaggedPropertyMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/FlaggedPropertyMap.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/FlaggedPropertyMap.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/FlaggedPropertyMap.java Tue Jan 5 11:48:54 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -23,7 +23,6 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-
import java.util.Set;
import javax.faces.context.FacesContext;
@@ -32,6 +31,7 @@
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.bean.PropertyMap;
+
public class FlaggedPropertyMap extends AbstractMap<PropertyKey,Object>
implements PropertyMap
{
@@ -176,6 +176,24 @@
map.markInitialState();
}
+ public void clearInitialState()
+ {
+ PropertyMap map = getPropertyMap(false);
+ if (map != null)
+ map.clearInitialState();
+ }
+
+ public boolean initialStateMarked()
+ {
+ PropertyMap map = getPropertyMap(false);
+
+ if (map != null)
+ return map.initialStateMarked();
+
+ // TODO gcrawford - do something better?
+ return false;
+ }
+
public Object saveState(FacesContext context)
{
PropertyMap map = getPropertyMap(false);
@@ -194,7 +212,6 @@
StateUtils.restoreState(this, context, type, state, getUseStateHolder());
}
-
public boolean getUseStateHolder()
{
return _useStateHolder;
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java Tue Jan 5 11:48:54 2010
@@ -141,6 +141,17 @@
}
+ public void clearInitialState()
+ {
+ _initialStateMarked = false;
+ _deltas = null;
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _initialStateMarked;
+ }
+
private boolean _createDeltas()
{
if (_initialStateMarked)
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java Tue Jan 5 11:48:54 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,11 +21,12 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.context.FacesContext;
+
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.bean.PropertyMap;
-import javax.faces.context.FacesContext;
public class PropertyHashMap extends HashMap<PropertyKey,Object>
implements PropertyMap
@@ -77,7 +78,7 @@
{
if (!super.containsKey(key))
return null;
-
+
// If this key is contained, it certainly must be a PropertyKey!
assert(key instanceof PropertyKey);
_deltas.put((PropertyKey) key, null);
@@ -118,7 +119,6 @@
StateUtils.restoreState(this, context, type, state, getUseStateHolder());
}
-
protected PropertyMap createDeltaPropertyMap()
{
PropertyHashMap map = new PropertyHashMap(2);
@@ -126,7 +126,6 @@
return map;
}
-
public boolean getUseStateHolder()
{
return _useStateHolder;
@@ -137,7 +136,6 @@
_useStateHolder = useStateHolder;
}
-
// =-=AEW CLEAR?
public void markInitialState()
@@ -145,6 +143,16 @@
_initialStateMarked = true;
}
+ public void clearInitialState()
+ {
+ _initialStateMarked = false;
+ _deltas = null;
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _initialStateMarked;
+ }
private boolean _createDeltas()
{
@@ -157,7 +165,7 @@
return true;
}
-
+
return false;
}
@@ -177,4 +185,5 @@
private boolean _useStateHolder;
private static final long serialVersionUID = 1L;
+
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/FacesBeanWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/FacesBeanWrapper.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/FacesBeanWrapper.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/FacesBeanWrapper.java Tue Jan 5 11:48:54 2010
@@ -19,10 +19,13 @@
package org.apache.myfaces.trinidad.component;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.el.ValueExpression;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
@@ -96,6 +99,16 @@
_wrapped.setValueBinding(key, binding);
}
+ public void addClientBehavior(String eventName, ClientBehavior behavior)
+ {
+ _wrapped.addClientBehavior(eventName, behavior);
+ }
+
+ public Map<String, List<ClientBehavior>> getClientBehaviors()
+ {
+ return _wrapped.getClientBehaviors();
+ }
+
public void addEntry(PropertyKey listKey, Object value)
{
_wrapped.addEntry(listKey, value);
@@ -136,11 +149,6 @@
return _wrapped.bindingKeySet();
}
- public void markInitialState()
- {
- _wrapped.markInitialState();
- }
-
public Object saveState(FacesContext context)
{
return _wrapped.saveState(context);
@@ -150,4 +158,19 @@
{
_wrapped.restoreState(context, state);
}
+
+ public void clearInitialState()
+ {
+ _wrapped.clearInitialState();
+ }
+
+ public void markInitialState()
+ {
+ _wrapped.markInitialState();
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _wrapped.initialStateMarked();
+ }
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Tue Jan 5 11:48:54 2010
@@ -26,6 +26,7 @@
import javax.el.MethodExpression;
import javax.faces.component.NamingContainer;
+import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
@@ -792,4 +793,24 @@
* @see UIXComponentBase#getClientId(FacesContext context)
*/
abstract public String getContainerClientId(FacesContext context, UIComponent child);
+
+ /**
+ * We are using FacesBean to save state, which does not implement StateHelper, so
+ * calling this method will call UnsupportedOperationException
+ */
+ @Override
+ protected StateHelper getStateHelper()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * We are using FacesBean to save state, which does not implement StateHelper, so
+ * calling this method will call UnsupportedOperationException
+ */
+ @Override
+ protected StateHelper getStateHelper(boolean create)
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Tue Jan 5 11:48:54 2010
@@ -25,6 +25,7 @@
import java.net.URL;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -40,6 +41,8 @@
import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
@@ -47,6 +50,9 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
+import javax.faces.event.PostAddToViewEvent;
+import javax.faces.event.PreRemoveFromViewEvent;
+import javax.faces.event.PreRenderComponentEvent;
import javax.faces.render.RenderKit;
import javax.faces.render.Renderer;
@@ -261,8 +267,6 @@
}
}
-
-
/**
*/
@Override
@@ -282,7 +286,6 @@
return getFacesBean().getValueBinding(key);
}
-
@Override
public void setValueBinding(String name, ValueBinding binding)
{
@@ -293,7 +296,6 @@
getFacesBean().setValueBinding(key, binding);
}
-
@Override
public Map<String, Object> getAttributes()
{
@@ -305,8 +307,6 @@
// ------------------------------------------------------------- Properties
-
-
@Override
public String getClientId(FacesContext context)
{
@@ -354,7 +354,6 @@
return clientId;
}
-
/**
* Gets the identifier for the component.
*/
@@ -364,7 +363,6 @@
return (String) getProperty(ID_KEY);
}
-
/**
* Sets the identifier for the component. The identifier
* must follow a subset of the syntax allowed in HTML:
@@ -388,32 +386,55 @@
setProperty(ID_KEY, id);
}
-
-
@Override
abstract public String getFamily();
-
@Override
public UIComponent getParent()
{
return _parent;
}
-
/**
* <p>Set the parent <code>UIComponent</code> of this
* <code>UIComponent</code>.</p>
- *
+ *
* @param parent The new parent, or <code>null</code> for the root node
* of a component tree
*/
@Override
public void setParent(UIComponent parent)
{
- _parent = parent;
- }
+ // do we add this component ?
+ if (parent != null)
+ {
+ // set the reference
+ _parent = parent;
+
+ if (parent.isInView())
+ {
+ // trigger the ADD_EVENT and call setInView(true)
+ // recursive for all kids/facets...
+ // Application.publishEvent(java.lang.Class, java.lang.Object) must be called, passing
+ // PostAddToViewEvent.class as the first argument and the newly added component as the second
+ // argument.
+ _publishPostAddToViewEvent(getFacesContext(), this);
+ }
+ }
+ else
+ {
+ if (_parent != null && _parent.isInView())
+ {
+ // trigger the "remove event" lifecycle
+ // and call setInView(false) for all children/facets
+ // doing this => recursive
+ _publishPreRemoveFromViewEvent(getFacesContext(), this);
+ }
+ // (un)set the reference
+ _parent = parent;
+ }
+ }
@Override
public boolean isRendered()
@@ -421,7 +442,6 @@
return getBooleanProperty(RENDERED_KEY, true);
}
-
@Override
public void setRendered(boolean rendered)
{
@@ -470,7 +490,6 @@
setProperty(RENDERER_TYPE_KEY, rendererType);
}
-
@Override
public boolean getRendersChildren()
{
@@ -481,13 +500,8 @@
return renderer.getRendersChildren();
}
-
-
-
// ------------------------------------------------ Tree Management Methods
-
-
@Override
public UIComponent findComponent(String id)
{
@@ -558,8 +572,6 @@
}
}
-
-
/**
* <p>Create (if necessary) and return a List of the children associated
* with this component.</p>
@@ -581,7 +593,6 @@
return getChildren().size();
}
-
/**
* <p>Create (if necessary) and return a Map of the facets associated
* with this component.</p>
@@ -596,7 +607,6 @@
return _facets;
}
-
@Override
public UIComponent getFacet(String facetName)
{
@@ -607,7 +617,6 @@
return getFacets().get(facetName);
}
-
/**
* Returns an Iterator over the names of all facets.
* Unlike getFacets().keySet().iterator(), this does
@@ -638,7 +647,7 @@
if (_children == null)
return _facets.values().iterator();
}
-
+
return new CompositeIterator<UIComponent>(_children.iterator(), _facets.values().iterator());
}
@@ -655,7 +664,7 @@
_LOG.fine("Broadcasting event " + event + " to " + this);
UIComponent component = event.getComponent();
- if (component != null && satisfiesPartialTrigger(event))
+ if (component != null)
{
RequestContext adfContext = RequestContext.getCurrentInstance();
if (adfContext != null)
@@ -680,22 +689,8 @@
}
}
- /**
- * Check if a faces event broadcast to this component should trigger the partial updates of the
- * target listeners of this component. By default, all events trigger a partial update of the listeners.
- *
- * @param event The event to check
- * @return true if the partial triggers should be updated by this event being broadcast
- */
- protected boolean satisfiesPartialTrigger(
- FacesEvent event)
- {
- return true;
- }
-
// ------------------------------------------- Lifecycle Processing Methods
-
@Override
public void decode(FacesContext context)
{
@@ -721,11 +716,17 @@
if (context == null)
throw new NullPointerException();
+ // Call UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ pushComponentToEL(context, this);
+
if (!isRendered())
return;
+ context.getApplication().publishEvent(context, PreRenderComponentEvent.class, UIComponent.class, this);
+
_cacheRenderer(context);
Renderer renderer = getRenderer(context);
+
// if there is a Renderer for this component
if (renderer != null)
{
@@ -756,15 +757,22 @@
if (context == null)
throw new NullPointerException();
- if (isRendered())
+ try
{
- Renderer renderer = getRenderer(context);
- // if there is a Renderer for this component
- if (renderer != null)
+ if (isRendered())
{
- renderer.encodeEnd(context, this);
+ Renderer renderer = getRenderer(context);
+ // if there is a Renderer for this component
+ if (renderer != null)
+ {
+ renderer.encodeEnd(context, this);
+ }
}
}
+ finally
+ {
+ popComponentFromEL(context);
+ }
}
/**
@@ -809,12 +817,23 @@
if (!isRendered())
return;
- // Process all facets and children of this component
- decodeChildren(context);
+ pushComponentToEL(context, this);
+
+ try
+ {
+ // Process all facets and children of this component
+ decodeChildren(context);
- // Process this component itself
- decode(context);
+ // Process this component itself
+ decode(context);
+ }
+ finally
+ {
+ // Call UIComponent.popComponentFromEL(javax.faces.context.FacesContext) from inside of a finally
+ // block, just before returning.
+ popComponentFromEL(context);
+ }
}
@Override
@@ -826,8 +845,17 @@
if (!isRendered())
return;
- // Process all facets and children of this component
- validateChildren(context);
+ pushComponentToEL(context, this);
+
+ try
+ {
+ // Process all facets and children of this component
+ validateChildren(context);
+ }
+ finally
+ {
+ popComponentFromEL(context);
+ }
}
@Override
@@ -839,8 +867,17 @@
if (!isRendered())
return;
- // Process all facets and children of this component
- updateChildren(context);
+ pushComponentToEL(context, this);
+
+ try
+ {
+ // Process all facets and children of this component
+ updateChildren(context);
+ }
+ finally
+ {
+ popComponentFromEL(context);
+ }
}
@Override
@@ -851,9 +888,11 @@
if (_LOG.isFiner())
_LOG.finer("processSaveState() on " + this);
-
+
+ pushComponentToEL(context, this);
+
Object state = null;
-
+
try
{
if (((_children == null) || _children.isEmpty()) &&
@@ -867,17 +906,22 @@
treeState.saveState(context, this);
if (treeState.isEmpty())
state = null;
-
+
state = treeState;
}
}
catch (RuntimeException e)
{
_LOG.warning(_LOG.getMessage("COMPONENT_CHILDREN_SAVED_STATE_FAILED", this));
-
+
throw e;
}
-
+
+ finally
+ {
+ popComponentFromEL(context);
+ }
+
// if component state serialization checking is on, attempt to Serialize the
// component state immediately in order to determine which component's state
// failed state saving. Note that since our parent will attempt this same
@@ -888,7 +932,7 @@
{
try
{
- new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(state);
+ new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(state);
}
catch (IOException e)
{
@@ -912,16 +956,25 @@
if (_LOG.isFiner())
_LOG.finer("processRestoreState() on " + this);
- // If we saved a "TreeState", use it to restore everything
- if (state instanceof TreeState)
+ pushComponentToEL(context, this);
+
+ try
{
- ((TreeState) state).restoreState(context, this);
+ // If we saved a "TreeState", use it to restore everything
+ if (state instanceof TreeState)
+ {
+ ((TreeState) state).restoreState(context, this);
+ }
+ // Otherwise, we had no children or facets, and just use
+ // the "state" object
+ else
+ {
+ restoreState(context, state);
+ }
}
- // Otherwise, we had no children or facets, and just use
- // the "state" object
- else
+ finally
{
- restoreState(context, state);
+ popComponentFromEL(context);
}
}
@@ -934,16 +987,29 @@
getFacesBean().markInitialState();
}
- public Object saveState(FacesContext context)
+ @Override
+ public void clearInitialState()
{
- return getFacesBean().saveState(context);
+ getFacesBean().clearInitialState();
}
- public void restoreState(FacesContext context, Object stateObj)
+ @Override
+ public boolean initialStateMarked()
{
- getFacesBean().restoreState(context, stateObj);
+ return getFacesBean().initialStateMarked();
}
+ public Object saveState(FacesContext facesContext)
+ {
+ return getFacesBean().saveState(facesContext);
+ }
+
+ public void restoreState(
+ FacesContext facesContext,
+ Object stateObj)
+ {
+ getFacesBean().restoreState(facesContext, stateObj);
+ }
@Override
public String toString()
@@ -968,7 +1034,6 @@
return FacesContext.getCurrentInstance();
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls decodeChildrenImpl.
@@ -1003,7 +1068,6 @@
}
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls validateChildrenImpl.
@@ -1039,7 +1103,6 @@
}
}
-
/**
* Delegates to LifecycleRenderer, if present,
* otherwise calls upateChildrenImpl.
@@ -1122,6 +1185,81 @@
}
}
+ /**
+ * Publish PostAddToViewEvent to the component and all facets and children.
+ *
+ * @param context the current FacesContext
+ * @param component the current UIComponent
+ */
+ private void _publishPostAddToViewEvent(
+ FacesContext context,
+ UIComponent component)
+ {
+ component.setInView(true);
+ context.getApplication().publishEvent(context, PostAddToViewEvent.class, UIComponent.class, component);
+
+ if (component.getChildCount() > 0)
+ {
+ List<UIComponent> children = component.getChildren();
+ UIComponent child = null;
+ UIComponent currentChild = null;
+ int i = 0;
+ while (i < children.size())
+ {
+ child = children.get(i);
+
+ // Iterate over the same index if the component was removed
+ // This prevents skip components when processing
+ do
+ {
+ _publishPostAddToViewEvent(context, child);
+ currentChild = child;
+ }
+ while ((i < children.size()) &&
+ ((child = children.get(i)) != currentChild) );
+ i++;
+ }
+ }
+
+ if (component.getFacetCount() > 0)
+ {
+ for (UIComponent child : component.getFacets().values())
+ {
+ _publishPostAddToViewEvent(context, child);
+ }
+ }
+ }
+
+ /**
+ * Publish PreRemoveFromViewEvent to the component and all facets and children.
+ *
+ * @param context the current FacesContext
+ * @param component the current UIComponent
+ */
+ private void _publishPreRemoveFromViewEvent(
+ FacesContext context,
+ UIComponent component)
+ {
+ component.setInView(false);
+ context.getApplication().publishEvent(context, PreRemoveFromViewEvent.class, UIComponent.class, component);
+
+ if (component.getChildCount() > 0)
+ {
+ for (UIComponent child : component.getChildren())
+ {
+ _publishPreRemoveFromViewEvent(context, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0)
+ {
+ for (UIComponent child : component.getFacets().values())
+ {
+ _publishPreRemoveFromViewEvent(context, child);
+ }
+ }
+ }
+
private void _cacheRenderer(FacesContext context)
{
Renderer renderer = _getRendererImpl(context);
@@ -1225,7 +1363,6 @@
return n.intValue();
}
-
/**
* Return the number of facets. This is more efficient than
* calling getFacets().size();
@@ -1239,7 +1376,6 @@
return _facets.size();
}
-
/**
* Broadcast an event to a MethodBinding.
* This can be used to support MethodBindings such as the "actionListener"
@@ -1325,14 +1461,14 @@
throws FacesException
{
Iterator<UIComponent> children = getFacetsAndChildren();
-
+
boolean found = false;
-
+
while (children.hasNext() && !found)
{
found = children.next().invokeOnComponent(context, clientId, callback);
}
-
+
return found;
}
@@ -1352,7 +1488,7 @@
throws FacesException
{
assert this instanceof NamingContainer : "Only use invokeOnNamingContainerComponent on NamingContainers";
-
+
String thisClientId = getClientId(context);
if (clientId.equals(thisClientId))
@@ -1372,10 +1508,10 @@
}
boolean invokedComponent = false;
-
+
// set up the context for visiting the children
setupVisitingContext(context);
-
+
try
{
// iterate through children. We inline this code instead of calling super in order
@@ -1387,11 +1523,10 @@
// teardown the context now that we have visited the children
tearDownVisitingContext(context);
}
-
+
return invokedComponent;
}
}
-
/**
* Override to calls the hooks for setting up and tearing down the
@@ -1405,7 +1540,7 @@
String clientId,
ContextCallback callback)
throws FacesException
- {
+ {
String thisClientId = getClientId(context);
if (clientId.equals(thisClientId))
@@ -1416,10 +1551,10 @@
else
{
boolean invokedComponent = false;
-
+
// set up the context for visiting the children
setupVisitingContext(context);
-
+
try
{
// iterate through children. We inline this code instead of calling super in order
@@ -1431,12 +1566,87 @@
// teardown the context now that we have visited the children
tearDownVisitingContext(context);
}
-
+
return invokedComponent;
}
}
+ // ------------------------- Client behavior holder methods -------------------------
+ /**
+ * Utility method to assist sub-classes in the implementation of the
+ * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
+ * <p>This method must only
+ * be called by classes that implement the interface, doing otherwise will result in an exception.
+ * </p>
+ * @param eventName The event name
+ * @param behavior The behavior to add
+ * @see javax.faces.component.behavior.ClientBehaviorHolder#addClientBehavior(String, ClientBehavior)
+ */
+ protected void addClientBehavior(
+ String eventName,
+ ClientBehavior behavior)
+ {
+ // This will throw a class cast exception when illegally called by a class that does not
+ // implement ClientBehaviorHolder
+ Collection<String> events = ((ClientBehaviorHolder)this).getEventNames();
+
+ // This will throw a null pointer exception if the component author did not correctly implement
+ // the ClientBehaviorHolder contract which requires a non-empty collection to be returned from
+ // getEventNames
+ if (!events.contains(eventName))
+ {
+ return;
+ }
+
+ getFacesBean().addClientBehavior(eventName, behavior);
+ }
+
+ // Note, we do not need to provide a default implementation for the event names, as client
+ // behavior holder components must provide a non-empty list of event names. UIComponentBase
+ // decided to return a non-valid null in their code, but that is only confusing to the user, it
+ // is better to not implement the method and force the users to write the method upon interface
+ // implementation.
+ //protected Collection<String> getEventNames() {}
+
+ /**
+ * Utility method to assist sub-classes in the implementation of the
+ * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
+ * <p>This method must only
+ * be called by classes that implement the interface, doing otherwise will result in an exception.
+ * </p>
+ * @see javax.faces.component.behavior.ClientBehaviorHolder#getClientBehaviors()
+ * @return Read-only map of the client behaviors for this component
+ */
+ protected Map<String, List<ClientBehavior>> getClientBehaviors()
+ {
+ return getFacesBean().getClientBehaviors();
+ }
+
+ /**
+ * Utility method to assist sub-classes in the implementation of the
+ * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
+ * <p>This method must only
+ * be called by classes that implement the interface, doing otherwise will result in an exception.
+ * </p>
+ * @return null
+ * @see javax.faces.component.behavior.ClientBehaviorHolder#getDefaultEventName()
+ */
+ protected String getDefaultEventName()
+ {
+ _ensureClientBehaviorHolder();
+ return null;
+ }
+
+ private void _ensureClientBehaviorHolder()
+ {
+ if (!(this instanceof ClientBehaviorHolder))
+ {
+ throw new IllegalStateException("Component must implement ClientBehaviorHolder in order " +
+ "to make use of this method.");
+ }
+ }
+ // ------------------------- End of the client behavior holder methods -------------------------
/**
* <p>
@@ -1516,7 +1726,6 @@
}
}
-
static private UIComponent _findInsideOf(
UIComponent from,
String id)
@@ -1619,7 +1828,6 @@
private static final Iterator<UIComponent> _EMPTY_UICOMPONENT_ITERATOR =
new EmptyIterator<UIComponent>();
-
static private final ThreadLocal<StringBuilder> _STRING_BUILDER =
ThreadLocalUtils.newRequestThreadLocal();
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ExternalContextDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ExternalContextDecorator.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ExternalContextDecorator.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ExternalContextDecorator.java Tue Jan 5 11:48:54 2010
@@ -18,289 +18,19 @@
*/
package org.apache.myfaces.trinidad.context;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.Principal;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Set;
-import java.util.Map;
-
import javax.faces.context.ExternalContext;
+import javax.faces.context.ExternalContextWrapper;
/**
* Base class for decorating ExternalContexts.
*
*/
-abstract public class ExternalContextDecorator extends ExternalContext
+abstract public class ExternalContextDecorator extends ExternalContextWrapper
{
- @Override
- public void dispatch(String path) throws IOException
- {
- getExternalContext().dispatch(path);
- }
-
- @Override
- public Object getContext()
- {
- return getExternalContext().getContext();
- }
-
- @Override
- public Object getRequest()
- {
- return getExternalContext().getRequest();
- }
-
- @Override
- public String getRequestCharacterEncoding()
- {
- return getExternalContext().getRequestCharacterEncoding();
- }
-
- @Override
- public String getRequestContentType()
- {
- return getExternalContext().getRequestContentType();
- }
-
- @Override
- public Object getResponse()
- {
- return getExternalContext().getResponse();
- }
-
- @Override
- public String getResponseCharacterEncoding()
- {
- return getExternalContext().getResponseCharacterEncoding();
- }
-
- @Override
- public String getResponseContentType()
- {
- return getExternalContext().getResponseContentType();
- }
-
- @Override
- public Object getSession(boolean create)
- {
- return getExternalContext().getSession(create);
- }
-
- @Override
- public String getRequestContextPath()
- {
- return getExternalContext().getRequestContextPath();
- }
-
- @Override
- public String getRequestPathInfo()
- {
- return getExternalContext().getRequestPathInfo();
- }
-
- @Override
- public String getRequestServletPath()
- {
- return getExternalContext().getRequestServletPath();
- }
-
- @Override
- public String getInitParameter(String name)
- {
- return getExternalContext().getInitParameter(name);
- }
-
- @Override
- public String encodeResourceURL(String url)
- {
- return getExternalContext().encodeResourceURL(url);
- }
-
- @Override
- public String encodeActionURL(String url)
- {
- return getExternalContext().encodeActionURL(url);
- }
-
- @Override
- public String encodeNamespace(String ns)
- {
- return getExternalContext().encodeNamespace(ns);
- }
-
- @Override
- public String getAuthType()
- {
- return getExternalContext().getAuthType();
- }
-
- @Override
- public String getRemoteUser()
- {
- return getExternalContext().getRemoteUser();
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- return getExternalContext().getUserPrincipal();
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- return getExternalContext().isUserInRole(role);
- }
-
- @Override
- public URL getResource(String path) throws MalformedURLException
- {
- return getExternalContext().getResource(path);
- }
-
- @Override
- public InputStream getResourceAsStream(String path)
- {
- return getExternalContext().getResourceAsStream(path);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Set getResourcePaths(String path)
- {
- return getExternalContext().getResourcePaths(path);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestParameterMap()
- {
- return getExternalContext().getRequestParameterMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestParameterValuesMap()
- {
- return getExternalContext().getRequestParameterValuesMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterator getRequestParameterNames()
- {
- return getExternalContext().getRequestParameterNames();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestCookieMap()
- {
- return getExternalContext().getRequestCookieMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestHeaderMap()
- {
- return getExternalContext().getRequestHeaderMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestHeaderValuesMap()
- {
- return getExternalContext().getRequestHeaderValuesMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getInitParameterMap()
- {
- return getExternalContext().getInitParameterMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getApplicationMap()
- {
- return getExternalContext().getApplicationMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getSessionMap()
- {
- return getExternalContext().getSessionMap();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getRequestMap()
- {
- return getExternalContext().getRequestMap();
- }
-
- @Override
- public Locale getRequestLocale()
- {
- return getExternalContext().getRequestLocale();
- }
-
- @Override
- public void setRequest(Object request)
- {
- getExternalContext().setRequest(request);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException
- {
- getExternalContext().setRequestCharacterEncoding(encoding);
- }
-
- @Override
- public void setResponse(Object response)
- {
- getExternalContext().setResponse(response);
- }
-
- @Override
- public void setResponseCharacterEncoding(String encoding)
- {
- getExternalContext().setResponseCharacterEncoding(encoding);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterator getRequestLocales()
- {
- return getExternalContext().getRequestLocales();
- }
-
- @Override
- public void log(String message)
- {
- getExternalContext().log(message);
- }
-
- @Override
- public void log(String message, Throwable t)
- {
- getExternalContext().log(message, t);
- }
-
- @Override
- public void redirect(String url) throws IOException
+ public ExternalContext getWrapped()
{
- getExternalContext().redirect(url);
+ return getExternalContext();
}
abstract protected ExternalContext getExternalContext();
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java Tue Jan 5 11:48:54 2010
@@ -282,7 +282,7 @@
if (typeIdx == _PATTERN_TYPE)
{
- // We call this since the pattern may contain the generic currency sign '¤', which we don't
+ // We call this since the pattern may contain the generic currency sign, which we don't
// want to display to the user.
pattern = getLocalizedPattern(context, pattern, dfs);
@@ -750,7 +750,7 @@
}
/**
- * If <code>pattern</code> contains the generic currency sign '¤', this method will replace it
+ * If <code>pattern</code> contains the generic currency sign, this method will replace it
* with the localized currency symbol (if one exists).
* @param context the FacesContext
* @param pattern the pattern to be localized
@@ -762,13 +762,13 @@
if (pattern == null)
return null;
- // If the pattern contains the generic currency sign '¤', replace it with the localized
+ // If the pattern contains the generic currency sign, replace it with the localized
// currency symbol (if one exists), so that when the pattern is displayed (such as in an error
// message), it is more meaningful to the user.
- // If the pattern contains '¤¤', replace it with the international currency symbol.
+ // If the pattern contains double international currency symbol, replace it with the international currency symbol.
// For an explanation of this behavior, see section "Special Pattern Characters" at:
// http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html
- // The unicode for '¤' is: \u00A4
+ // The unicode for the international currency symbol is: \u00A4
// The xml hex is : ¤
int idx = pattern.indexOf('\u00A4');
if (idx == -1)
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java Tue Jan 5 11:48:54 2010
@@ -18,13 +18,20 @@
*/
package org.apache.myfaces.trinidad.render;
+
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import javax.faces.application.ResourceHandler;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
@@ -74,10 +81,10 @@
* @return The VisitResult controlling continued iteration of the visit.
*/
public VisitResult partialEncodeVisit(
- VisitContext visitContext,
+ VisitContext visitContext,
PartialPageContext partialContext,
- UIComponent component,
- VisitCallback callback)
+ UIComponent component,
+ VisitCallback callback)
{
if (partialContext.isPossiblePartialTarget(component.getId()) &&
partialContext.isPartialTarget(component.getClientId(visitContext.getFacesContext())))
@@ -109,16 +116,16 @@
* @see #tearDownEncodingContext
*/
public void setupEncodingContext(
- FacesContext context,
+ FacesContext context,
RenderingContext rc,
- UIXComponent component)
+ UIXComponent component)
{
}
public void setupEncodingContext(
- FacesContext context,
+ FacesContext context,
RenderingContext rc,
- UIComponent component)
+ UIComponent component)
{
// temporary hack to change UIComponent. Once the change has propagated through, we will
// remove the UIXComponent version.
@@ -143,16 +150,16 @@
* @see #setupEncodingContext
*/
public void tearDownEncodingContext(
- FacesContext context,
+ FacesContext context,
RenderingContext rc,
UIXComponent component)
{
}
public void tearDownEncodingContext(
- FacesContext context,
+ FacesContext context,
RenderingContext rc,
- UIComponent component)
+ UIComponent component)
{
// temporary hack to change UIComponent. Once the change has propagated through, we will
// remove the UIXComponent version.
@@ -161,7 +168,6 @@
tearDownEncodingContext(context, rc, (UIXComponent)component);
}
-
//
// COERCION HELPERS
//
@@ -186,6 +192,25 @@
String uri = o.toString();
+ // *** EL Coercion problem ***
+ // If icon or image attribute was declared with #{resource[]} and that expression
+ // evaluates to null (it means ResourceHandler.createResource returns null because requested resource does not exist)
+ // EL implementation turns null into ""
+ // see http://www.irian.at/blog/blogid/unifiedElCoercion/#unifiedElCoercion
+ if (uri.length() == 0)
+ {
+ return null;
+ }
+
+
+ // With JSF 2.0 url for resources can be done with EL like #{resource['resourcename']}
+ // and such EL after evalution contains context path for the current web application already,
+ // -> we dont want call viewHandler.getResourceURL()
+ if (uri.contains(ResourceHandler.RESOURCE_IDENTIFIER))
+ {
+ return uri;
+ }
+
// Treat two slashes as server-relative
if (uri.startsWith("//"))
{
@@ -193,6 +218,9 @@
}
else
{
+ // If the specified path starts with a "/",
+ // following method will prefix it with the context path for the current web application,
+ // and return the result
return fc.getApplication().getViewHandler().getResourceURL(fc, uri);
}
}
@@ -218,7 +246,6 @@
}
}
-
/**
* Coerces an object into a resource URI, calling the view-handler.
* @deprecated use toResourceUri
@@ -228,7 +255,6 @@
return toResourceUri(FacesContext.getCurrentInstance(),o);
}
-
/**
* Returns the integer value of an object; this does
* not support null (which must be substituted with a default
@@ -239,8 +265,6 @@
return ((Number) o).intValue();
}
-
-
/**
* Returns the integer value of an object; this does
* not support null (which must be substituted with a default
@@ -293,10 +317,11 @@
return c;
}
-
@Override
- public final void encodeBegin(FacesContext context,
- UIComponent component) throws IOException
+ public final void encodeBegin(
+ FacesContext context,
+ UIComponent component
+ ) throws IOException
{
if (!getRendersChildren())
{
@@ -313,15 +338,19 @@
}
@Override
- public final void encodeChildren(FacesContext context, UIComponent component)
+ public final void encodeChildren(
+ FacesContext context,
+ UIComponent component)
{
// encodeChildren() is fairly useless - it's simpler to just
// put the output in encodeEnd(), or use the encodeAll() hook
}
@Override
- public final void encodeEnd(FacesContext context,
- UIComponent component) throws IOException
+ public final void encodeEnd(
+ FacesContext context,
+ UIComponent component
+ ) throws IOException
{
RenderingContext rc = RenderingContext.getCurrentInstance();
if (rc == null)
@@ -349,13 +378,36 @@
FacesContext context,
RenderingContext rc,
UIComponent component,
- FacesBean bean) throws IOException
+ FacesBean bean
+ ) throws IOException
{
if (getRendersChildren())
throw new IllegalStateException();
}
/**
+ * Hook for rendering the component resources for the <code>target</code>.
+ * @param context Current <code>FacesContext</code> object for this request.
+ * @param target The target for the resources (e.g. head/body/form)
+ *
+ * @throws IOException
+ */
+ protected final void encodeComponentResources(
+ FacesContext context,
+ String target
+ ) throws IOException
+ {
+ if(target != null)
+ {
+ UIViewRoot viewRoot = context.getViewRoot();
+ for(UIComponent componentResource : viewRoot.getComponentResources(context, target))
+ {
+ componentResource.encodeAll(context);
+ }
+ }
+ }
+
+ /**
* Hook for rendering the end of a component; only
* called if getRendersChildren() is <em>false</em>.
*/
@@ -363,13 +415,13 @@
FacesContext context,
RenderingContext rc,
UIComponent component,
- FacesBean bean) throws IOException
+ FacesBean bean
+ ) throws IOException
{
if (getRendersChildren())
throw new IllegalStateException();
}
-
/**
* Hook for rendering all of a component; only
* called if getRendersChildren() is <em>true</em>.
@@ -378,7 +430,8 @@
FacesContext context,
RenderingContext rc,
UIComponent component,
- FacesBean bean) throws IOException
+ FacesBean bean
+ ) throws IOException
{
if (!getRendersChildren())
throw new IllegalStateException();
@@ -393,7 +446,8 @@
@SuppressWarnings("unchecked")
protected void encodeChild(
FacesContext context,
- UIComponent child) throws IOException
+ UIComponent child
+ ) throws IOException
{
assert(child.isRendered());
child.encodeBegin(context);
@@ -415,11 +469,11 @@
child.encodeEnd(context);
}
-
@SuppressWarnings("unchecked")
protected void encodeAllChildren(
FacesContext context,
- UIComponent component) throws IOException
+ UIComponent component
+ ) throws IOException
{
int childCount = component.getChildCount();
if (childCount == 0)
@@ -439,7 +493,8 @@
RenderingContext rc,
UIComponent component,
FacesBean bean,
- CoreRenderer renderer) throws IOException
+ CoreRenderer renderer
+ ) throws IOException
{
if (renderer.getRendersChildren())
{
@@ -456,7 +511,8 @@
RenderingContext rc,
UIComponent component,
FacesBean bean,
- CoreRenderer renderer) throws IOException
+ CoreRenderer renderer
+ ) throws IOException
{
if (renderer.getRendersChildren())
{
@@ -473,7 +529,8 @@
RenderingContext rc,
UIComponent component,
FacesBean bean,
- CoreRenderer renderer) throws IOException
+ CoreRenderer renderer
+ ) throws IOException
{
if (renderer.getRendersChildren())
{
@@ -490,7 +547,8 @@
*/
protected void renderId(
FacesContext context,
- UIComponent component) throws IOException
+ UIComponent component
+ ) throws IOException
{
if (shouldRenderId(context, component))
{
@@ -517,7 +575,7 @@
// TODO Is this a bottleneck? If so, optimize!
protected boolean shouldRenderId(
FacesContext context,
- UIComponent component)
+ UIComponent component)
{
String id = component.getId();
@@ -532,12 +590,14 @@
return true;
}
- protected boolean skipDecode(FacesContext context)
+ protected boolean skipDecode(
+ FacesContext context)
{
return false;
}
- protected FacesBean getFacesBean(UIComponent component)
+ protected FacesBean getFacesBean(
+ UIComponent component)
{
return ((UIXComponent) component).getFacesBean();
}
@@ -576,7 +636,8 @@
* one has rendered=="true".
*/
@SuppressWarnings("unchecked")
- static public boolean hasRenderedChildren(UIComponent component)
+ static public boolean hasRenderedChildren(
+ UIComponent component)
{
int count = component.getChildCount();
if (count == 0)
@@ -597,7 +658,8 @@
* Returns the total number of children with rendered=="true".
*/
@SuppressWarnings("unchecked")
- static public int getRenderedChildCount(UIComponent component)
+ static public int getRenderedChildCount(
+ UIComponent component)
{
int count = component.getChildCount();
if (count == 0)
@@ -615,7 +677,6 @@
return total;
}
-
/**
* @param afterChildIndex The children coming after this index, will
* be considered.
@@ -624,7 +685,7 @@
*/
public static int getNextRenderedChildIndex(
List<UIComponent> components,
- int afterChildIndex
+ int afterChildIndex
)
{
int childIndex = afterChildIndex + 1;
@@ -640,7 +701,6 @@
return NO_CHILD_INDEX;
}
-
//
// AGENT CAPABILITY CONVENIENCE METHODS
//
@@ -750,6 +810,41 @@
// Rendering convenience methods.
//
+ /**
+ * Get a collection of all the parameters that are children of the current component as
+ * client behavior parameters.
+ * @param component The component
+ * @return Collection of parameters (will be non-null)
+ */
+ public static Collection<ClientBehaviorContext.Parameter> getBehaviorParameters(
+ UIComponent component)
+ {
+ int childCount = component.getChildCount();
+ if (childCount > 0)
+ {
+ List<ClientBehaviorContext.Parameter> list = null;
+ for (UIComponent child : component.getChildren())
+ {
+ if (!(child instanceof UIParameter)) { continue; }
+
+ if (list == null)
+ {
+ // leave plenty of room to hold the parameters
+ list = new ArrayList<ClientBehaviorContext.Parameter>(childCount);
+ }
+ UIParameter param = (UIParameter) child;
+ list.add(new ClientBehaviorContext.Parameter(param.getName(), param.getValue()));
+ }
+
+ if (list != null)
+ {
+ return list;
+ }
+ }
+
+ return Collections.<ClientBehaviorContext.Parameter>emptyList();
+ }
+
protected void renderEncodedActionURI(
FacesContext context,
String name,
@@ -774,8 +869,6 @@
}
}
-
-
/**
* Render a generic CSS styleClass (not one derived from an attribute).
* The styleclass will be passed through the RenderingContext
@@ -847,7 +940,6 @@
context.getResponseWriter().writeAttribute("class", value, null);
}
-
// Heuristic guess of the maximum length of a typical compressed style
private static final int _COMPRESSED_LENGTH = 4;
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ResourceServlet.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ResourceServlet.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ResourceServlet.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ResourceServlet.java Tue Jan 5 11:48:54 2010
@@ -36,10 +36,14 @@
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
+import javax.faces.application.ProjectStage;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.event.PhaseListener;
import javax.faces.lifecycle.Lifecycle;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -403,11 +407,120 @@
debug = config.getServletContext().getInitParameter(DEBUG_INIT_PARAM);
}
- _debug = "true".equalsIgnoreCase(debug);
+ // private call to get the used JSF 2.0 ProjectStage as we don't have
+ // access to the FacesContext object here...
+ ProjectStage currentStage = _getFacesProjectStage(config.getServletContext());
+
+ if (debug != null)
+ {
+ _debug = "true".equalsIgnoreCase(debug);
+ }
+ else
+ {
+ // if the DDEBUG_INIT_PARAM parameter has NOT been specified, let us
+ // apply the DEFAULT values for the certain Project Stages:
+ // -PRODUCTION we want this value to be FALSE;
+ // -other stages we use TRUE
+ _debug = !(ProjectStage.Production.equals(currentStage));
+ }
+
if (_debug)
{
- _LOG.info("RESOURCESERVLET_IN_DEBUG_MODE",DEBUG_INIT_PARAM);
+ // If DEBUG_INIT_PARAM is TRUE on Production-Stage, we
+ // generate a WARNING msg
+ if (ProjectStage.Production.equals(currentStage))
+ {
+ _LOG.warning("RESOURCESERVLET_IN_DEBUG_MODE",DEBUG_INIT_PARAM);
+ }
+ else
+ {
+ _LOG.info("RESOURCESERVLET_IN_DEBUG_MODE",DEBUG_INIT_PARAM);
+ }
+ }
+ }
+
+ /**
+ * private version of the <code>Application.getProjectStage()</code>. See the
+ * original JavaDoc for a description of the underlying algorithm.
+ *
+ * It is written as we do not have access to the FacesContext object at the point
+ * of executing this method.
+ *
+ * This code comes from the <b>Apache MyFaces 2.0</b> implementation.
+ */
+ private ProjectStage _getFacesProjectStage(ServletContext servletContext)
+ {
+ if (_projectStage == null)
+ {
+ String stageName = null;
+ // Look for a JNDI environment entry under the key given by the
+ // value of ProjectStage.PROJECT_STAGE_JNDI_NAME (a String)
+ try
+ {
+ Context ctx = new InitialContext();
+ Object temp = ctx.lookup(ProjectStage.PROJECT_STAGE_JNDI_NAME);
+ if (temp != null)
+ {
+ if (temp instanceof String)
+ {
+ stageName = (String) temp;
+ }
+ else
+ {
+ if (_LOG.isSevere())
+ {
+ _LOG.severe("Invalid JNDI lookup for key " + ProjectStage.PROJECT_STAGE_JNDI_NAME);
+ }
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ // no-op we need to ignore this...
+ }
+
+ /*
+ * If found, continue with the algorithm below, otherwise, look for an entry in the initParamMap of the
+ * ExternalContext from the current FacesContext with the key ProjectStage.PROJECT_STAGE_PARAM_NAME
+ */
+ if (stageName == null)
+ {
+ stageName = servletContext.getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME);
+ }
+
+ // If a value is found found
+ if (stageName != null)
+ {
+ /*
+ * see if an enum constant can be obtained by calling ProjectStage.valueOf(), passing the value from the
+ * initParamMap. If this succeeds without exception, save the value and return it.
+ */
+ try
+ {
+ _projectStage = ProjectStage.valueOf(stageName);
+ return _projectStage;
+ }
+ catch (IllegalArgumentException e)
+ {
+ _LOG.severe("Couldn't discover the current project stage", e);
+ }
+ }
+ else
+ {
+ if (_LOG.isInfo())
+ {
+ _LOG.info("Couldn't discover the current project stage, using " + ProjectStage.Production);
+ }
+ }
+ /*
+ * If not found, or any of the previous attempts to discover the enum constant value have failed, log a
+ * descriptive error message, assign the value as ProjectStage.Production and return it.
+ */
+
+ _projectStage = ProjectStage.Production;
}
+
+ return _projectStage;
}
/**
@@ -569,4 +682,5 @@
private Map<String, ResourceLoader> _loaders;
private FacesContextFactory _facesContextFactory;
private Lifecycle _lifecycle;
+ private ProjectStage _projectStage;
}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/FindComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/FindComponentTest.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/FindComponentTest.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/FindComponentTest.java Tue Jan 5 11:48:54 2010
@@ -23,13 +23,15 @@
import javax.faces.component.UIForm;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.myfaces.trinidad.component.UIXPanel;
+import org.apache.myfaces.trinidadbuild.test.FacesTestCase;
-public class FindComponentTest extends TestCase
+public class FindComponentTest extends FacesTestCase
{
public static final Test suite()
{
@@ -156,6 +158,7 @@
UIXPanel g = new UIXPanel(); g.setId("g");
UIXPanel h = new UIXPanel(); h.setId("h");
UIXPanel i = new UIXPanel(); i.setId("i");
+
a.getChildren().add(b);
a.getChildren().add(c);
b.getChildren().add(d);
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/convert/NumberConverterTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/convert/NumberConverterTestCase.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/convert/NumberConverterTestCase.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/convert/NumberConverterTestCase.java Tue Jan 5 11:48:54 2010
@@ -217,28 +217,7 @@
}
}
-// public void testFranceLocale()
-// {
-// NumberConverter converter = getNumberConverter();
-// Mock mock = mock(UIComponent.class);
-// UIComponent comp = (UIComponent) mock.proxy();
-//
-// converter.setLocale(Locale.FRANCE);
-// converter.setType("currency");
-// Double d = new Double(12345.68d);
-//
-// setFacesContext(facesContext);
-// try
-// {
-// String convertedString = converter.getAsString(facesContext, comp, d);
-// assertEquals("12 345,68 ", convertedString);
-// }
-// finally
-// {
-// setFacesContext(null);
-// }
-// mock.verify();
-// }
+
public void testCurrencyCodeIsHonoured()
{
@@ -579,4 +558,4 @@
// Pattern tested
// Type tested
// GroupingUsed tested
-// IntegerOnly tested // only while parsing
\ No newline at end of file
+// IntegerOnly tested // only while parsing
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java Tue Jan 5 11:48:54 2010
@@ -18,7 +18,6 @@
*/
package org.apache.myfaces.trinidad.util;
-import junit.framework.TestCase;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
@@ -31,8 +30,9 @@
import org.apache.myfaces.trinidad.component.UIXInput;
import org.apache.myfaces.trinidad.component.UIXPanel;
import org.apache.myfaces.trinidad.component.UIXTable;
+import org.apache.myfaces.trinidadbuild.test.FacesTestCase;
-public class FindRelativeComponentTest extends TestCase
+public class FindRelativeComponentTest extends FacesTestCase
{
public static final Test suite()
{
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidadbuild/test/MockFacesContext12.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidadbuild/test/MockFacesContext12.java?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidadbuild/test/MockFacesContext12.java (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-api/src/test/java/org/apache/myfaces/trinidadbuild/test/MockFacesContext12.java Tue Jan 5 11:48:54 2010
@@ -18,14 +18,27 @@
*/
package org.apache.myfaces.trinidadbuild.test;
+import java.util.Collection;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
import javax.el.ELContext;
import javax.faces.application.Application;
+import javax.faces.application.ApplicationWrapper;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+import javax.faces.context.PartialViewContext;
+import javax.faces.event.PhaseId;
+import javax.faces.event.SystemEvent;
import javax.faces.lifecycle.Lifecycle;
import org.apache.shale.test.mock.MockFacesContext;
+import org.apache.shale.test.mock.MockApplication12;
+
public class MockFacesContext12 extends MockFacesContext
{
@@ -36,12 +49,14 @@
super(ec, lifecycle);
elContext = createELContext(application);
elContext.putContext(FacesContext.class, this);
+ _app = application;
}
public MockFacesContext12(Application application)
{
elContext = createELContext(application);
elContext.putContext(FacesContext.class, this);
+ _app = application;
}
public ELContext getELContext()
@@ -53,6 +68,104 @@
{
return new MockELContext(application);
}
+
+ public Map<Object,Object> getAttributes()
+ {
+ return _attrs;
+ }
+
+ public PartialViewContext getPartialViewContext()
+ {
+ return _mockPartialContext;
+ }
+
+ public Application getApplication()
+ {
+ return new ApplicationWrapper()
+ {
+ public Application getWrapped()
+ {
+ return _app;
+ }
+ public void publishEvent(FacesContext context,
+ Class<? extends SystemEvent> systemEventClass,
+ Class<?> sourceBaseType,
+ Object source)
+ {
+ // do nothing
+ }
+
+ public void publishEvent(FacesContext context,
+ Class<? extends SystemEvent> systemEventClass,
+ Object source)
+ {
+ //do nothing
+ }
+ };
+ }
protected MockELContext elContext;
-}
\ No newline at end of file
+
+
+ private final PartialViewContext _mockPartialContext = new MockPartialViewContext();
+ private final Map<Object, Object> _attrs = new HashMap<Object, Object>();
+ private Application _app;
+
+ private static class MockPartialViewContext extends PartialViewContext
+ {
+ public Collection<String> getExecuteIds()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<String> getRenderIds()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PartialResponseWriter getPartialResponseWriter()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAjaxRequest()
+ {
+ return false;
+ }
+
+ public boolean isPartialRequest()
+ {
+ return false;
+ }
+
+ public boolean isExecuteAll()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isRenderAll()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setRenderAll(boolean renderAll)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setPartialRequest(boolean isPartialRequest)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void release()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void processPartial(PhaseId phaseId)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-assembly/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-assembly/pom.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-assembly/pom.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-assembly/pom.xml Tue Jan 5 11:48:54 2010
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.myfaces.trinidad</groupId>
<artifactId>trinidad</artifactId>
- <version>1.2.12.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>trinidad-assembly</artifactId>
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/pom.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/pom.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/pom.xml Tue Jan 5 11:48:54 2010
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.myfaces.trinidad</groupId>
<artifactId>trinidad</artifactId>
- <version>1.2.12.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>trinidad-build</artifactId>
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml Tue Jan 5 11:48:54 2010
@@ -16,7 +16,7 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-
+
-->
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:tr="http://myfaces.apache.org/trinidad"
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreBreadCrumbs.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreBreadCrumbs.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreBreadCrumbs.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreBreadCrumbs.xml Tue Jan 5 11:48:54 2010
@@ -98,6 +98,9 @@
<mfp:author>Blake Sullivan</mfp:author>
<mfp:component-metadata/>
<mfp:uix2-local-name>breadCrumbs</mfp:uix2-local-name>
+ <fmd:default-event-name>click</fmd:default-event-name>
+ <fmd:event-names>click dblclick mousedown mouseup mouseover mousemove mouseout
+ keypress keydown keyup</fmd:event-names>
<fmd:component-metadata>
<fmd:preferred-child-components>org.apache.myfaces.trinidad.CoreCommandNavigationItem</fmd:preferred-child-components>
</fmd:component-metadata>
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseColor.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseColor.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseColor.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseColor.xml Tue Jan 5 11:48:54 2010
@@ -143,6 +143,9 @@
<mfp:unsupported-agents>pda phone voice</mfp:unsupported-agents>
</mfp:component-metadata>
<mfp:uix2-local-name>colorPalette</mfp:uix2-local-name>
+ <fmd:default-event-name>click</fmd:default-event-name>
+ <fmd:event-names>click dblclick mousedown mouseup mouseover mousemove mouseout
+ keypress keydown keyup</fmd:event-names>
<fmd:component-metadata>
<fmd:allowed-child-components>NONE</fmd:allowed-child-components>
</fmd:component-metadata>
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml Tue Jan 5 11:48:54 2010
@@ -122,6 +122,9 @@
<mfp:unsupported-agents>pda phone</mfp:unsupported-agents>
</mfp:component-metadata>
<mfp:uix2-local-name>inlineDatePicker</mfp:uix2-local-name>
+ <fmd:default-event-name>click</fmd:default-event-name>
+ <fmd:event-names>click dblclick mousedown mouseup mouseover mousemove mouseout
+ keypress keydown keyup</fmd:event-names>
<fmd:component-metadata>
<fmd:allowed-child-components>NONE</fmd:allowed-child-components>
</fmd:component-metadata>
Modified: myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreColumn.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreColumn.xml?rev=896009&r1=896008&r2=896009&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreColumn.xml (original)
+++ myfaces/trinidad/branches/2.0.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreColumn.xml Tue Jan 5 11:48:54 2010
@@ -255,6 +255,9 @@
<mfp:author>Brian Albers</mfp:author>
<mfp:component-metadata/>
<mfp:uix2-local-name>column</mfp:uix2-local-name>
+ <fmd:default-event-name>click</fmd:default-event-name>
+ <fmd:event-names>click dblclick mousedown mouseup mouseover mousemove mouseout
+ keypress keydown keyup</fmd:event-names>
<fmd:component-metadata>
<fmd:default-property>headerText</fmd:default-property>
<fmd:preferred-child-components>org.apache.myfaces.trinidad.CoreOutputText</fmd:preferred-child-components>