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 2006/06/18 21:15:43 UTC

svn commit: r415178 - in /myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces: event/ event/SetPropertyActionListener.java taglib/core/SetPropertyActionListener.java taglib/core/SetPropertyActionListenerTag.java

Author: matzew
Date: Sun Jun 18 12:15:42 2006
New Revision: 415178

URL: http://svn.apache.org/viewvc?rev=415178&view=rev
Log:
removing the ActionListener away from taglib package.

Added:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/SetPropertyActionListener.java
Removed:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java
Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/SetPropertyActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/SetPropertyActionListener.java?rev=415178&view=auto
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/SetPropertyActionListener.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/event/SetPropertyActionListener.java Sun Jun 18 12:15:42 2006
@@ -0,0 +1,103 @@
+package org.apache.myfaces.event;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+/**
+ * TODO this really needs to be under javax.faces.*
+ * 
+ * @author Dennis Byrne
+ * @since 1.2
+ */
+
+public class SetPropertyActionListener implements ActionListener, StateHolder
+{
+
+    private ValueExpression target;
+    
+    private ValueExpression value;
+    
+    private boolean _transient ;
+    
+    public SetPropertyActionListener(){}
+    
+    public SetPropertyActionListener(ValueExpression target, ValueExpression value)
+    {
+        this.target = target;
+        this.value = value;
+    }
+    
+    public void processAction(ActionEvent actionEvent) throws AbortProcessingException
+    {
+        
+        if( target == null )
+            throw new AbortProcessingException("@target has not been set");
+
+        if( value == null )
+            throw new AbortProcessingException("@value has not been set");
+        
+        FacesContext ctx = FacesContext.getCurrentInstance();
+        
+        if( ctx == null )
+            throw new AbortProcessingException("FacesContext ctx is null");
+        
+        ELContext ectx = ctx.getELContext();
+        
+        if( ectx == null )
+            throw new AbortProcessingException("ELContext ectx is null");
+        
+        target.setValue(ectx, value.getValue(ectx));
+        
+    }
+
+    public Object saveState(FacesContext context)
+    {
+        Object[] state = new Object[2];
+        state[0] = target;
+        state[1] = value;
+        return state;
+    }
+
+    public void restoreState(FacesContext context, Object state)
+    {
+        Object[] values = new Object[2];
+        target = (ValueExpression) values[0];
+        value = (ValueExpression) values[1];
+    }
+
+    public boolean isTransient()
+    {
+        return _transient;
+    }
+
+    public void setTransient(boolean _transient)
+    {
+        this._transient = _transient;
+    }
+
+    public ValueExpression getTarget()
+    {
+        return target;
+    }
+
+    public void setTarget(ValueExpression target)
+    {
+        this.target = target;
+    }
+
+    public ValueExpression getValue()
+    {
+        return value;
+    }
+
+    public void setValue(ValueExpression value)
+    {
+        this.value = value;
+    }
+
+}

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java?rev=415178&r1=415177&r2=415178&view=diff
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java Sun Jun 18 12:15:42 2006
@@ -11,6 +11,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.myfaces.event.SetPropertyActionListener;
+
 /**
  * @author Dennis Byrne
  * @since 1.2