You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2007/03/01 20:57:35 UTC
svn commit: r513469 - in
/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component:
UIComponent.java UIComponentBase.java
Author: mbr
Date: Thu Mar 1 11:57:34 2007
New Revision: 513469
URL: http://svn.apache.org/viewvc?view=rev&rev=513469
Log:
get/set methods for valueExpression must be implemented in UIComponent
Modified:
myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponent.java
myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponentBase.java
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponent.java?view=diff&rev=513469&r1=513468&r2=513469
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponent.java Thu Mar 1 11:57:34 2007
@@ -19,6 +19,8 @@
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
+
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -33,7 +35,7 @@
implements StateHolder
{
- protected Map<String,ValueExpression> bindings;
+ protected Map<String,ValueExpression> bindings;
public UIComponent()
{
@@ -46,7 +48,13 @@
*/
public abstract javax.faces.el.ValueBinding getValueBinding(java.lang.String name);
- public abstract ValueExpression getValueExpression(String name);
+ public ValueExpression getValueExpression(String name) {
+ if (name == null) throw new NullPointerException("name can not be null");
+
+ if (bindings == null) return null;
+
+ return bindings.get(name);
+ }
/**
* @deprecated Replaced by setValueExpression
@@ -54,7 +62,32 @@
public abstract void setValueBinding(java.lang.String name,
javax.faces.el.ValueBinding binding);
- public abstract void setValueExpression(String name, ValueExpression binding);
+ public void setValueExpression(String name, ValueExpression binding) {
+ if (name == null) throw new NullPointerException("name");
+ if (name.equals("id")) throw new IllegalArgumentException("Can't set a ValueExpression for the 'id' property.");
+ if (name.equals("parent")) throw new IllegalArgumentException("Can't set a ValueExpression for the 'parent' property.");
+
+ if(binding == null) {
+ this.getAttributes().remove(name);
+ }
+
+ if (binding.isLiteralText()) {
+ try {
+ Object value = binding.getValue(getFacesContext().getELContext());
+ this.getAttributes().put(name, value);
+ return;
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+
+ }
+
+ if (bindings == null) {
+ bindings = new HashMap<String, ValueExpression>();
+ }
+
+ bindings.put(name, binding);
+ }
/**
* Invokes the <code>invokeContextCallback</code> method with the component, specified by <code>clientId</code>.
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponentBase.java?view=diff&rev=513469&r1=513468&r2=513469
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/UIComponentBase.java Thu Mar 1 11:57:34 2007
@@ -156,14 +156,6 @@
return new _ValueExpressionToValueBinding(expression);
}
-
- public ValueExpression getValueExpression(String name) {
- if (name == null) throw new NullPointerException("name can not be null");
-
- if (_valueExpressionMap == null) return null;
-
- return _valueExpressionMap.get(name);
- }
/**
* Put the provided value-binding into a map of value-bindings
@@ -175,29 +167,6 @@
ValueBinding binding)
{
setValueExpression(name, new _ValueBindingToValueExpression(binding));
- }
-
- public void setValueExpression(String name, ValueExpression binding) {
- if (name == null) throw new NullPointerException("name");
- if (name.equals("id")) throw new IllegalArgumentException("Can't set a ValueExpression for the 'id' property.");
- if (name.equals("parent")) throw new IllegalArgumentException("Can't set a ValueExpression for the 'parent' property.");
-
- if (binding.isLiteralText()) {
- try {
- Object value = binding.getValue(getFacesContext().getELContext());
- this.getAttributes().put(name, value);
- return;
- } catch (Exception e) {
- throw new FacesException(e);
- }
-
- }
-
- if (_valueExpressionMap == null) {
- _valueExpressionMap = new HashMap<String, ValueExpression>();
- }
-
- _valueExpressionMap.put(name, binding);
}
/**