myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r226969 - in /myfaces: examples/trunk/simple/ examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/ tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ tomahawk/trunk/tld/
Date Tue, 02 Aug 2005 08:42:06 GMT
Author: mbr
Date: Tue Aug  2 01:41:56 2005
New Revision: 226969

URL: http://svn.apache.org/viewcvs?rev=226969&view=rev
Log:
actionListener property added to datascroller

Modified:
    myfaces/examples/trunk/simple/dataScroller.jsp
    myfaces/examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
    myfaces/tomahawk/trunk/tld/myfaces_ext.tld

Modified: myfaces/examples/trunk/simple/dataScroller.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/simple/dataScroller.jsp?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/examples/trunk/simple/dataScroller.jsp (original)
+++ myfaces/examples/trunk/simple/dataScroller.jsp Tue Aug  2 01:41:56 2005
@@ -32,7 +32,7 @@
     <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
 
     <h:panelGroup id="body">
-
+    
         <x:dataTable id="data"
                 styleClass="scrollerTable"
                 headerClass="standardTable_Header"
@@ -77,6 +77,7 @@
                     paginatorMaxPages="9"
                     paginatorTableClass="paginator"
                     paginatorActiveColumnStyle="font-weight:bold;"
+                    actionListener="#{scrollerList.scrollerAction}"
                     >
                 <f:facet name="first" >
                     <x:graphicImage url="images/arrow-first.gif" border="1" />
@@ -118,7 +119,7 @@
         </h:panelGrid>
 
     </h:panelGroup>
-
+        
 </f:view>
 
 <%@include file="inc/page_footer.jsp" %>

Modified: myfaces/examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/DataScrollerList.java?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
(original)
+++ myfaces/examples/trunk/simple/src/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
Tue Aug  2 01:41:56 2005
@@ -18,6 +18,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.custom.datascroller.ScrollerActionEvent;
+
 /**
  * DOCUMENT ME!
  * @author Thomas Spiegl (latest modification by $Author$)
@@ -26,9 +31,6 @@
 public class DataScrollerList
 {
     private List _list = new ArrayList();
-    static
-    {
-    }
 
     public DataScrollerList()
     {
@@ -43,4 +45,13 @@
         return _list;
     }
 
+    public void scrollerAction(ActionEvent event)
+    {
+        ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+        FacesContext.getCurrentInstance().getExternalContext().log(
+                        "scrollerAction: facet: "
+                                        + scrollerEvent.getScrollerfacet()
+                                        + ", pageindex: "
+                                        + scrollerEvent.getPageIndex());
+    }
 }

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
(original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
Tue Aug  2 01:41:56 2005
@@ -19,6 +19,7 @@
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIData;
 import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
 import javax.faces.el.MethodBinding;
 import javax.faces.el.ValueBinding;
 import javax.faces.event.AbortProcessingException;
@@ -31,6 +32,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
 
+import sun.reflect.generics.scope.Scope;
+
 /**
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
@@ -49,6 +52,8 @@
 	// just for caching the associated uidata
 	private transient UIData _UIData;
 
+    private MethodBinding _actionListener;
+
 	/**
 	 * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
 	 */
@@ -75,9 +80,12 @@
 	{
 		super.broadcast(event);
 
-		if (event instanceof ScrollerActionEvent)
+        if (event instanceof ScrollerActionEvent)
 		{
-			ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+            ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+
+            broadcastToActionListener(scrollerEvent);
+            
 			UIData uiData = getUIData();
 			if (uiData == null)
 			{
@@ -158,6 +166,32 @@
 	}
 
 	/**
+     * @param event
+     */
+    protected void broadcastToActionListener(ScrollerActionEvent event)
+    {
+        FacesContext context = getFacesContext();
+
+        MethodBinding actionListenerBinding = getActionListener();
+        if (actionListenerBinding != null)
+        {
+            try
+            {
+                actionListenerBinding.invoke(context, new Object[] {event});
+            }
+            catch (EvaluationException e)
+            {
+                Throwable cause = e.getCause();
+                if (cause != null && cause instanceof AbortProcessingException)
+                {
+                    throw (AbortProcessingException)cause;
+                }
+                throw e;
+            }
+        }
+    }
+
+    /**
 	 * @return int
 	 */
 	public UIData getUIData()
@@ -353,22 +387,21 @@
 						"defining an action is not supported. use an actionlistener");
 	}
 
-	/**
-	 * @see javax.faces.component.ActionSource#getActionListener()
-	 */
-	public MethodBinding getActionListener()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
-	 */
-	public void setActionListener(MethodBinding actionListener)
-	{
-		throw new UnsupportedOperationException(
-						"defining an action is not supported. use an actionlistener");
-	}
+    /**
+     * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+     */
+    public void setActionListener(MethodBinding actionListener)
+    {
+        _actionListener = actionListener;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#getActionListener()
+     */
+    public MethodBinding getActionListener()
+    {
+        return _actionListener;
+    }
 
 	/**
 	 * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
@@ -707,7 +740,7 @@
 
 	public Object saveState(FacesContext context)
 	{
-		Object values[] = new Object[22];
+		Object values[] = new Object[23];
 		values[0] = super.saveState(context);
 		values[1] = _for;
 		values[2] = _fastStep;
@@ -730,6 +763,7 @@
 		values[19] = _paginatorActiveColumnStyle;
 		values[20] = _renderFacetsIfSinglePage;
 		values[21] = _immediate;
+        values[22] = saveAttachedState(context, _actionListener);
 		return values;
 	}
 
@@ -758,6 +792,7 @@
 		_paginatorActiveColumnStyle = (String) values[19];
 		_renderFacetsIfSinglePage = (Boolean) values[20];
 		_immediate = (Boolean) values[21];
+        _actionListener = (MethodBinding)restoreAttachedState(context, values[22]);
 	}
 
 	//------------------ GENERATED CODE END ---------------------------------------

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
(original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
Tue Aug  2 01:41:56 2005
@@ -117,6 +117,7 @@
 	private String _renderFacetsIfSinglePage;
 	
     private String _immediate;
+    private String _actionListener;
 
     // User Role support
     private String _enabledOnUserRole;
@@ -146,6 +147,7 @@
         _enabledOnUserRole=null;
         _visibleOnUserRole=null;
         _immediate=null;
+        _actionListener=null;
     }
     
     public String getComponentType()
@@ -183,6 +185,7 @@
 		setBooleanProperty(component, RENDER_FACETS_IF_SINGLE_PAGE_ATTR, _renderFacetsIfSinglePage);
 		
         setBooleanProperty(component, JSFAttr.IMMEDIATE_ATTR, _immediate);
+        setActionListenerProperty(component, _actionListener);
 
         setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR, _enabledOnUserRole);
         setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR, _visibleOnUserRole);
@@ -287,6 +290,11 @@
     public void setImmediate(String immediate)
     {
         _immediate = immediate;
+    }
+
+    public void setActionListener(String actionListener)
+    {
+        _actionListener = actionListener;
     }
 
     // userrole attributes

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
(original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
Tue Aug  2 01:41:56 2005
@@ -1,11 +1,26 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.myfaces.custom.datascroller;
 
 import javax.faces.component.UIComponent;
 import javax.faces.event.ActionEvent;
 
 /**
- * @author MBroekelmann
- *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
  */
 public class ScrollerActionEvent extends ActionEvent
 {

Modified: myfaces/tomahawk/trunk/tld/myfaces_ext.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/tld/myfaces_ext.tld?rev=226969&r1=226968&r2=226969&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/tld/myfaces_ext.tld (original)
+++ myfaces/tomahawk/trunk/tld/myfaces_ext.tld Tue Aug  2 01:41:56 2005
@@ -1162,6 +1162,13 @@
             <type>java.lang.String</type>
             <description>True means, that the default ActionListener should be executed
immediately (i.e. during Apply Request Values phase of the request processing lifecycle),
rather than waiting until the Invoke Application phase.</description>
         </attribute>
+        <attribute>
+            <name>actionListener</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+            <type>java.lang.String</type>
+            <description>MethodBinding pointing at method acception an ActionEvent
with return type void.</description>
+        </attribute>
      </tag>
 
     <!-- inputDate -->



Mime
View raw message