You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/01/12 00:19:22 UTC
svn commit: r1230320 - in /myfaces/core/branches/2.0.x/api/src/main:
java/javax/faces/component/html/_CommonEventConstants.java
resources/META-INF/componentClass20.vm
Author: lu4242
Date: Wed Jan 11 23:19:21 2012
New Revision: 1230320
URL: http://svn.apache.org/viewvc?rev=1230320&view=rev
Log:
MYFACES-3446 [perf] Improve html Renderers (Optimize client behaviors)
Added:
myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java (with props)
Modified:
myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm
Added: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java?rev=1230320&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java (added)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java Wed Jan 11 23:19:21 2012
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 javax.faces.component.html;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+
+/**
+ *
+ * @author lu4242
+ */
+class _CommonEventConstants
+{
+ public static final String COMMON_EVENTS_MARKED = "oam.COMMON_EVENTS_MARKED";
+
+ public static final long ACTION_EVENT = 0x1L;
+ public static final long CLICK_EVENT = 0x2L;
+ public static final long DBLCLICK_EVENT = 0x4L;
+ public static final long MOUSEDOWN_EVENT = 0x8L;
+ public static final long MOUSEUP_EVENT = 0x10L;
+ public static final long MOUSEOVER_EVENT = 0x20L;
+ public static final long MOUSEMOVE_EVENT = 0x40L;
+ public static final long MOUSEOUT_EVENT = 0x80L;
+ public static final long KEYPRESS_EVENT = 0x100L;
+ public static final long KEYDOWN_EVENT = 0x200L;
+ public static final long KEYUP_EVENT = 0x400L;
+ public static final long FOCUS_EVENT = 0x800L;
+ public static final long BLUR_EVENT = 0x1000L;
+ public static final long SELECT_EVENT = 0x2000L;
+ public static final long CHANGE_EVENT = 0x4000L;
+ public static final long VALUECHANGE_EVENT = 0x8000L;
+ public static final long LOAD_EVENT = 0x10000L;
+ public static final long UNLOAD_EVENT = 0x20000L;
+
+ public static final Map<String, Long> COMMON_EVENTS_KEY_BY_NAME = new HashMap<String, Long>(24,1);
+
+ static
+ {
+ //EVENTS
+ COMMON_EVENTS_KEY_BY_NAME.put("change", CHANGE_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("select", SELECT_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("click", CLICK_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("dblclick", DBLCLICK_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("mousedown",MOUSEDOWN_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("mouseup", MOUSEUP_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("mouseover",MOUSEOVER_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("mousemove",MOUSEMOVE_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("mouseout", MOUSEOUT_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("keypress", KEYPRESS_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("keydown", KEYDOWN_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("keyup", KEYUP_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("focus", FOCUS_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("blur", BLUR_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("load", LOAD_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("unload", UNLOAD_EVENT);
+ //virtual
+ COMMON_EVENTS_KEY_BY_NAME.put("valueChange", VALUECHANGE_EVENT);
+ COMMON_EVENTS_KEY_BY_NAME.put("action", ACTION_EVENT);
+ }
+
+ public static void markEvent(UIComponent component, String name)
+ {
+ Long propertyConstant = COMMON_EVENTS_KEY_BY_NAME.get(name);
+ if (propertyConstant == null)
+ {
+ return;
+ }
+ Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_EVENTS_MARKED);
+ if (commonPropertiesSet == null)
+ {
+ commonPropertiesSet = 0L;
+ }
+ component.getAttributes().put(COMMON_EVENTS_MARKED, commonPropertiesSet | propertyConstant);
+ }
+}
Propchange: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/html/_CommonEventConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm?rev=1230320&r1=1230319&r2=1230320&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm (original)
+++ myfaces/core/branches/2.0.x/api/src/main/resources/META-INF/componentClass20.vm Wed Jan 11 23:19:21 2012
@@ -115,13 +115,20 @@ $innersource
#end
#end
#end
-#end
));
public java.util.Collection<String> getEventNames()
{
return CLIENT_EVENTS_LIST;
}
+
+ @Override
+ public void addClientBehavior(String eventName, javax.faces.component.behavior.ClientBehavior behavior)
+ {
+ super.addClientBehavior(eventName, behavior);
+ _CommonEventConstants.markEvent(this, eventName);
+ }
+#end
#end
#if ($component.defaultEventName)
#if ($component.defaultEventName != "")