Author: jmitchell
Date: Mon Oct 16 18:20:34 2006
New Revision: 464765

URL: http://svn.apache.org/viewvc?view=rev&rev=464765
Log:
STR-2960
 - add actionListener to CommandLinkTag



Modified:
    
struts/struts1/trunk/apps/faces-example1/src/main/java/org/apache/struts/webapp/example/IndexBacking.java
    struts/struts1/trunk/apps/faces-example1/src/main/webapp/index.jsp
    
struts/struts1/trunk/faces/src/main/java/org/apache/struts/faces/taglib/CommandLinkTag.java
    struts/struts1/trunk/faces/src/main/resources/META-INF/tld/struts-faces.tld

Modified: 
struts/struts1/trunk/apps/faces-example1/src/main/java/org/apache/struts/webapp/example/IndexBacking.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/apps/faces-example1/src/main/java/org/apache/struts/webapp/example/IndexBacking.java?view=diff&rev=464765&r1=464764&r2=464765
==============================================================================
--- 
struts/struts1/trunk/apps/faces-example1/src/main/java/org/apache/struts/webapp/example/IndexBacking.java
 (original)
+++ 
struts/struts1/trunk/apps/faces-example1/src/main/java/org/apache/struts/webapp/example/IndexBacking.java
 Mon Oct 16 18:20:34 2006
@@ -19,6 +19,8 @@
 
 
 import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -54,7 +56,13 @@
         return (null);
 
     }
-
+    /**
+     * <p>Testing actionListener call</p>
+     * @param actionEvent
+     */
+    public void testListener(ActionEvent actionEvent){
+//     System.out.println("================= it works!!");
+    }
 
     /**
      * <p>Forward to the <em>Logon</em> page.</p>

Modified: struts/struts1/trunk/apps/faces-example1/src/main/webapp/index.jsp
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/apps/faces-example1/src/main/webapp/index.jsp?view=diff&rev=464765&r1=464764&r2=464765
==============================================================================
--- struts/struts1/trunk/apps/faces-example1/src/main/webapp/index.jsp 
(original)
+++ struts/struts1/trunk/apps/faces-example1/src/main/webapp/index.jsp Mon Oct 
16 18:20:34 2006
@@ -64,9 +64,16 @@
       <s:message      key="index.heading"/>
     </f:facet>
 
+    <s:commandLink     id="test"
+           actionListener="#{indexBacking.testListener}"
+                immediate="true"
+               styleClass="link"
+                 rendered="#{false}">
+               <h:outputText value="Click here to test 
ActionListener"></h:outputText>
+    </s:commandLink>
+
     <s:commandLink     id="create"
                    action="#{indexBacking.create}"
-                immediate="true"
                styleClass="link">
       <f:param       name="action"
                     value="Create"/>
@@ -79,6 +86,8 @@
                styleClass="link">
       <s:message      key="index.logon"/>
     </s:commandLink>
+    
+    <h:message for="test"></h:message>
 
   </h:panelGrid>
 

Modified: 
struts/struts1/trunk/faces/src/main/java/org/apache/struts/faces/taglib/CommandLinkTag.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/faces/src/main/java/org/apache/struts/faces/taglib/CommandLinkTag.java?view=diff&rev=464765&r1=464764&r2=464765
==============================================================================
--- 
struts/struts1/trunk/faces/src/main/java/org/apache/struts/faces/taglib/CommandLinkTag.java
 (original)
+++ 
struts/struts1/trunk/faces/src/main/java/org/apache/struts/faces/taglib/CommandLinkTag.java
 Mon Oct 16 18:20:34 2006
@@ -21,6 +21,7 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
+import javax.faces.event.ActionEvent;
 
 
 /**
@@ -38,6 +39,7 @@
 
     private String accesskey = null;
     private String action = null;
+    private String actionListener = null;
     private String charset = null;
     private String dir = null;
     private String hreflang = null;
@@ -78,6 +80,11 @@
     }
 
 
+    public void setactionListener(String actionListener) {
+       this.actionListener = actionListener;
+    }
+    
+    
     public void setCharset(String charset) {
         this.charset = charset;
     }
@@ -214,6 +221,7 @@
         super.release();
         accesskey = null;
         action = null;
+        actionListener = null;
         charset = null;
         dir = null;
         hreflang = null;
@@ -288,6 +296,14 @@
                 MethodBinding mb = new ConstantMethodBinding(outcome);
                 ((ActionSource) component).setAction(mb);
             }
+        }
+        if (actionListener != null) {
+               if (isValueReference(actionListener)) {
+                       Class[] args = {ActionEvent.class};
+                       MethodBinding mb = FacesContext.getCurrentInstance().
+                       getApplication().createMethodBinding(actionListener, 
args);
+                       ((ActionSource) component).setActionListener(mb);
+               }
         }
         setStringAttribute(component, "accesskey", accesskey);
         setStringAttribute(component, "charset", charset);

Modified: 
struts/struts1/trunk/faces/src/main/resources/META-INF/tld/struts-faces.tld
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/faces/src/main/resources/META-INF/tld/struts-faces.tld?view=diff&rev=464765&r1=464764&r2=464765
==============================================================================
--- struts/struts1/trunk/faces/src/main/resources/META-INF/tld/struts-faces.tld 
(original)
+++ struts/struts1/trunk/faces/src/main/resources/META-INF/tld/struts-faces.tld 
Mon Oct 16 18:20:34 2006
@@ -235,7 +235,7 @@
     <description><![CDATA[
       <p>Displays a list of error messages prepared by form bean
       or business logic validation processing.</p>
-<p>In order to use this component successfully, you must have
+      <p>In order to use this component successfully, you must have
       defined an application scope <code>MessageResources</code> bean
       under the specified attribute name, with optinal definitions for
       the following message keys:</p>


Reply via email to