myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r513958 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java
Date Fri, 02 Mar 2007 21:16:12 GMT
Author: imario
Date: Fri Mar  2 13:16:11 2007
New Revision: 513958

URL: http://svn.apache.org/viewvc?view=rev&rev=513958
Log:
TOMAHAWK-915, provide smarter default for event, e.g. change for select family components

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java?view=diff&rev=513958&r1=513957&r2=513958
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java
Fri Mar  2 13:16:11 2007
@@ -30,8 +30,15 @@
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.UICommand;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.UISelectItem;
+import javax.faces.component.UISelectMany;
+import javax.faces.component.UISelectOne;
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.TreeSet;
 
 /**
  * Attach an event handler to an input element or use a global event handler to
@@ -41,7 +48,14 @@
  */
 public class SubmitOnEventRenderer extends HtmlRenderer
 {
-    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
+	private final static Set ON_CHANGE_FAMILY = new TreeSet(Arrays.asList(new String[]
+	{
+		UISelectBoolean.COMPONENT_FAMILY,
+		UISelectMany.COMPONENT_FAMILY,
+		UISelectOne.COMPONENT_FAMILY
+	}));
+
+	public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
     {
         SubmitOnEvent submitOnEvent = (SubmitOnEvent) uiComponent;
 
@@ -95,8 +109,17 @@
         }
         else
         {
-            js.append("keypress");
-        }
+			if (forComponent != null
+				&& forComponent.getFamily() != null
+				&& ON_CHANGE_FAMILY.contains(forComponent.getFamily()))
+			{
+				js.append("change");
+			}
+			else
+			{
+				js.append("keypress");
+			}
+		}
         js.append("','");
         if (submitOnEvent.getCallback() != null)
         {



Mime
View raw message