myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1098552 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom: calendar/HtmlCalendarRenderer.java inputTextHelp/AbstractHtmlInputTextHelp.java inputTextHelp/HtmlTextHelpRenderer.java
Date Mon, 02 May 2011 13:18:20 GMT
Author: lu4242
Date: Mon May  2 13:18:19 2011
New Revision: 1098552

URL: http://svn.apache.org/viewvc?rev=1098552&view=rev
Log:
TOMAHAWK-1574 t:inputCalendar is not triggering f:ajax (fix clientBehaviors targetClientId
and input id passed to popup)

Modified:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/AbstractHtmlInputTextHelp.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=1098552&r1=1098551&r2=1098552&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
Mon May  2 13:18:19 2011
@@ -335,6 +335,8 @@ public class HtmlCalendarRenderer
         
         inputText.setName(inputCalendar.getClientId(facesContext));
         
+        inputText.setTargetClientId(inputCalendar.getClientId(facesContext));
+        
         ResponseWriter writer = facesContext.getResponseWriter();
         
         writer.startElement(HTML.SPAN_ELEM, inputCalendar);
@@ -382,7 +384,7 @@ public class HtmlCalendarRenderer
 
                         String clientVar = JavascriptUtils.getValidJavascriptName(clientId+"CalendarVar",true);
 
-                        return clientVar+"._popUpCalendar(this,document.getElementById('"+clientId+"'),'"+dateFormat+"')";
+                        return clientVar+"._popUpCalendar(this,document.getElementById('"+clientId+"_input'),'"+dateFormat+"')";
                     }
                 });
             }

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/AbstractHtmlInputTextHelp.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/AbstractHtmlInputTextHelp.java?rev=1098552&r1=1098551&r2=1098552&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/AbstractHtmlInputTextHelp.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/AbstractHtmlInputTextHelp.java
Mon May  2 13:18:19 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.myfaces.custom.inputTextHelp;
 
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 import org.apache.myfaces.component.html.ext.HtmlInputText;
 
 /**
@@ -52,8 +53,14 @@ public abstract class AbstractHtmlInputT
     public abstract boolean isSelectText();
     
     /**
-     * @JSFProperty
+     * Overrides the name field used by this input.
      */
+    @JSFProperty(tagExcluded=true)
     public abstract String getName();
-
+    
+    /**
+     * Overrides the targetClientId used for rendered client behaviors by this component.
+     */
+    @JSFProperty(tagExcluded=true)
+    public abstract String getTargetClientId();
 }

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java?rev=1098552&r1=1098551&r2=1098552&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
Mon May  2 13:18:19 2011
@@ -145,21 +145,26 @@ public class HtmlTextHelpRenderer extend
         }
         if (behaviors != null && !behaviors.isEmpty())
         {
+            String targetClientId = (String) component.getAttributes().get("targetClientId");
+            if (targetClientId == null)
+            {
+                targetClientId = component.getClientId(facesContext);
+            }
             
             HtmlRendererUtils.renderBehaviorizedEventHandlersWithoutOnclick(facesContext,
writer, component, behaviors);
-            HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer,
component, behaviors);
-            HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
component,
+            HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer,
component, targetClientId, behaviors);
+            HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONBLUR_ATTR,
component, targetClientId,
                     ClientBehaviorEvents.BLUR, behaviors, HTML.ONBLUR_ATTR);
-            HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer,  HTML.ONSELECT_ATTR,
component,
+            HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer,  HTML.ONSELECT_ATTR,
component, targetClientId,
                     ClientBehaviorEvents.SELECT, behaviors, HTML.ONSELECT_ATTR);
             HtmlRendererUtils.renderHTMLAttributes(writer, component,
                     HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
 
             if(!(component instanceof HtmlInputTextHelp) || getHelpText(component) == null
|| ("").equals(getHelpText(component).trim()))
             {
-                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
component,
+                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
component, targetClientId,
                         ClientBehaviorEvents.FOCUS, behaviors, HTML.ONFOCUS_ATTR);
-                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONCLICK_ATTR,
component,
+                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONCLICK_ATTR,
component, targetClientId,
                         ClientBehaviorEvents.CLICK, behaviors, HTML.ONCLICK_ATTR);
             }
             else
@@ -167,10 +172,10 @@ public class HtmlTextHelpRenderer extend
                 String id = component.getClientId(facesContext);
                 HtmlInputTextHelp textHelp = (HtmlInputTextHelp)component;
 
-                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
component, 
+                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONFOCUS_ATTR,
component, targetClientId,
                         ClientBehaviorEvents.FOCUS, null, behaviors, HTML.ONFOCUS_ATTR, null,
                         buildJavascriptFunction(component, id, textHelp.getOnfocus()));
-                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONCLICK_ATTR,
component, 
+                HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONCLICK_ATTR,
component, targetClientId,
                         ClientBehaviorEvents.CLICK, null, behaviors, HTML.ONCLICK_ATTR, null,
                         buildJavascriptFunction(component, id, textHelp.getOnclick()));
             }
@@ -201,6 +206,29 @@ public class HtmlTextHelpRenderer extend
         }
     }
     
+    public static void renderBehaviorizedEventHandlersWithoutOnclick(
+            FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent, String
targetClientId,
+            Map<String, List<ClientBehavior>> clientBehaviors) throws IOException
{
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONDBLCLICK_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.DBLCLICK, clientBehaviors, HTML.ONDBLCLICK_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEDOWN_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.MOUSEDOWN, clientBehaviors, HTML.ONMOUSEDOWN_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEUP_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.MOUSEUP, clientBehaviors, HTML.ONMOUSEUP_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEOVER_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.MOUSEOVER, clientBehaviors, HTML.ONMOUSEOVER_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEMOVE_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.MOUSEMOVE, clientBehaviors, HTML.ONMOUSEMOVE_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONMOUSEOUT_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.MOUSEOUT, clientBehaviors, HTML.ONMOUSEOUT_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYPRESS_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.KEYPRESS, clientBehaviors, HTML.ONKEYPRESS_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYDOWN_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.KEYDOWN, clientBehaviors, HTML.ONKEYDOWN_ATTR);
+        HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONKEYUP_ATTR,
uiComponent, targetClientId,
+                ClientBehaviorEvents.KEYUP, clientBehaviors, HTML.ONKEYUP_ATTR);
+    }    
+    
     private String buildJavascriptFunction(UIComponent component, String id, String componentScript)

     {
         StringBuffer jsFunction = new StringBuffer();



Mime
View raw message