[richfaces-svn-commits] JBoss Rich Faces SVN: r18972 - in trunk/ui/input/ui/src/main: java/org/richfaces/renderkit and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Aug 25 14:43:39 EDT 2010


Author: abelevich
Date: 2010-08-25 14:43:39 -0400 (Wed, 25 Aug 2010)
New Revision: 18972

Modified:
   trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
   trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
   trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
   trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
Log:
RF-9132, fix onblur behavior

Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java	2010-08-25 14:25:35 UTC (rev 18971)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java	2010-08-25 18:43:39 UTC (rev 18972)
@@ -24,6 +24,7 @@
 import javax.faces.component.UIInput;
 
 import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
 import org.richfaces.cdk.annotations.JsfComponent;
 import org.richfaces.cdk.annotations.JsfRenderer;
 import org.richfaces.cdk.annotations.Tag;
@@ -62,4 +63,84 @@
     
     @Attribute
     public abstract String getTabIndex();
+    
+    @Attribute(events=@EventName("blur"))
+    public abstract String getOnblur();
+
+    @Attribute(events=@EventName("click"))
+    public abstract String getOnclick();
+    
+    @Attribute(events=@EventName("ondblclick"))
+    public abstract String getOndblclick();
+   
+    @Attribute(events=@EventName("focus"))
+    public abstract String getOnfocus();
+    
+    @Attribute(events=@EventName("keydown"))
+    public abstract String getOnkeydown();
+    
+    @Attribute(events=@EventName("keypress"))
+    public abstract String getOnkeypress();
+    
+    @Attribute(events=@EventName("keyup"))
+    public abstract String getOnkeypup();
+    
+    @Attribute(events=@EventName("mousedown"))
+    public abstract String getOnmousedown();
+    
+    @Attribute(events=@EventName("mousemove"))
+    public abstract String getOnmousemove();
+    
+    @Attribute(events=@EventName("mouseout"))
+    public abstract String getOnmouseout();
+    
+    @Attribute(events=@EventName("mouseover"))
+    public abstract String getOnmouseover();
+    
+    @Attribute(events=@EventName("mouseup"))
+    public abstract String getOnmouseup();
+
+    @Attribute(events=@EventName("inputClick"))
+    public abstract String getOnInputClick();
+    
+    @Attribute(events=@EventName("inputDblclick"))
+    public abstract String getOnInputDblclick();
+    
+    @Attribute(events=@EventName("inputMousedown"))
+    public abstract String getOnInputMousedown();
+    
+    @Attribute(events=@EventName("inputMousemove"))
+    public abstract String getOnInputMousemove();
+    
+    @Attribute(events=@EventName("inputMouseout"))
+    public abstract String getOnInputMouseout();
+    
+    @Attribute(events=@EventName("inputMouseover"))
+    public abstract String getOnInputMouseover();
+    
+    @Attribute(events=@EventName("inputMouseup"))
+    public abstract String getOnInputMouseup();
+    
+    @Attribute(events=@EventName("inputKeydown"))
+    public abstract String getOnInputKeydown();
+    
+    @Attribute(events=@EventName("inputKeypress"))
+    public abstract String getOnInputKeypress();
+    
+    @Attribute(events=@EventName("oninputKeyup"))
+    public abstract String getOnInputKeypup();
+    
+    @Attribute(events=@EventName("inputFocus"))
+    public abstract String getOnInputFocus();
+  
+    @Attribute(events=@EventName("inputBlur"))
+    public abstract String getOnInputBlur();
+    
+    @Attribute(events=@EventName("select"))
+    public abstract String getOnselect();
+    
+    @Attribute(events=@EventName("change"))
+    public abstract String getOnchange();
+    
+    //TODO: what is default event?, add onViewActivated, onEditActivated events support
 }

Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java	2010-08-25 14:25:35 UTC (rev 18971)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java	2010-08-25 18:43:39 UTC (rev 18972)
@@ -22,6 +22,7 @@
 package org.richfaces.renderkit;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -35,6 +36,7 @@
 
 import org.ajax4jsf.javascript.JSFunction;
 import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
 import org.richfaces.component.AbstractInplaceInput;
 import org.richfaces.component.InplaceState;
 import org.richfaces.component.util.HtmlUtil;
@@ -57,6 +59,8 @@
     
     public static final String OPTIONS_INPUT = "input";
     
+    public static final String OPTIONS_FOCUS = "focusElement";
+    
     public static final String OPTIONS_BTN_OK = "okbtn";
     
     public static final String OPTIONS_LABEL = "label";
@@ -79,6 +83,38 @@
 
     private static final String NONE_CSS = "rf-ii-none";
     
+    private static final Map<String, ComponentAttribute> INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
+    .unmodifiableMap(ComponentAttribute.createMap(
+        new ComponentAttribute(HTML.ONCLICK_ATTRIBUTE).setEventNames("inputClick").
+            setComponentAttributeName("onInputClick"),
+        new ComponentAttribute(HTML.ONDBLCLICK_ATTRIBUTE).setEventNames("inputDblclick").
+            setComponentAttributeName("onInputDblclick"),
+        new ComponentAttribute(HTML.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputMousedown").
+            setComponentAttributeName("onInputMousedown"),
+        new ComponentAttribute(HTML.ONMOUSEUP_ATTRIBUTE).setEventNames("inputMouseup").
+            setComponentAttributeName("onInputMouseup"),
+        new ComponentAttribute(HTML.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputMouseover").
+            setComponentAttributeName("onInputMouseover"),
+        new ComponentAttribute(HTML.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputMousemove").
+            setComponentAttributeName("onInputMousemove"),
+        new ComponentAttribute(HTML.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputMouseout").
+            setComponentAttributeName("onInputMouseout"),
+        new ComponentAttribute(HTML.ONKEYPRESS_ATTRIBUTE).setEventNames("inputKeypress").
+            setComponentAttributeName("onInputKeypress"),
+        new ComponentAttribute(HTML.ONKEYDOWN_ATTRIBUTE).setEventNames("inputKeydown").
+            setComponentAttributeName("onInputKeydown"),
+        new ComponentAttribute(HTML.ONKEYUP_ATTRIBUTE).setEventNames("inputKeyup").
+            setComponentAttributeName("onInputKeyup"),
+        new ComponentAttribute(HTML.ONBLUR_ATTRIBUTE).setEventNames("inputBlur").
+            setComponentAttributeName("onInputBlur"),
+        new ComponentAttribute(HTML.ONFOCUS_ATTRIBUTE).setEventNames("inputFocus").
+            setComponentAttributeName("onInputFocus"),
+        new ComponentAttribute(HTML.ONCHANGE_ATTRIBUTE).setEventNames("change").
+            setComponentAttributeName("onchange"),
+        new ComponentAttribute(HTML.ONSELECT_ATTRIBUTE).setEventNames("select").
+            setComponentAttributeName("onselect")
+    ));
+
     
     @Override
     protected void doDecode(FacesContext facesContext, UIComponent component) {
@@ -90,6 +126,10 @@
         }
     }
 
+    protected void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
+        RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACEINPUT_HANDLER_ATTRIBUTES);
+    }
+    
     public InplaceState getInplaceState(UIComponent component) {
         return ((AbstractInplaceInput) component).getState();
     }
@@ -147,6 +187,7 @@
         options.put(OPTIONS_EDIT_CONTAINER, clientId + ":edit");
         options.put(OPTIONS_INPUT, clientId + ":input");
         options.put(OPTIONS_LABEL, clientId + ":label");
+        options.put(OPTIONS_FOCUS, clientId + ":focus");
         
         boolean showControls = inplaceInput.isShowControls();
         options.put(OPTIONS_SHOWCONTROLS, showControls);

Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js	2010-08-25 14:25:35 UTC (rev 18971)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js	2010-08-25 18:43:39 UTC (rev 18972)
@@ -29,7 +29,7 @@
     		this.attachToDom(id);
 
     		this.namespace = this.namespace || "."+rf.Event.createNamespace(this.name, this.id);
-
+    		
             this.currentState = options.state;
             this.editEvent = options.editEvent;
             this.noneCss = options.noneCss; 
@@ -40,6 +40,7 @@
             this.editContainer = $(document.getElementById(options.editContainer));
             this.input = $(document.getElementById(options.input));
             this.label = $(document.getElementById(options.label));
+            this.focusElement = $(document.getElementById(options.focusElement));
             this.initialValue = this.label.text();
             
             this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
@@ -94,13 +95,14 @@
            			}
            			isSaved = true;
        				this.__hide();
-           		}, 
+       			 }, 
            		
            		cancel: function() {
            			var text = this.label.text();
            			this.input.val(text);
            			isSaved = true;
                		this.__hide();
+       				this.element.focus();
            		},
            		
            		setValue: function (value) {
@@ -113,7 +115,7 @@
            		}, 
 
 /******************  private methods  *****************************************/
-
+           		
            		__saveBtnHandler: function(e) {
            			this.save();
            			return false;
@@ -140,6 +142,7 @@
            			if(!isSaved) {
            				this.save();
            			}
+           			return false;
            		},
            		
            		__scrollHandler: function(e) {
@@ -169,7 +172,7 @@
         			rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
         			this.scrollElements = null;
            			this.editContainer.addClass(this.noneCss);
-   					this.input.blur();
+           			this.focusElement.focus();
            		},
 
      			destroy: function () {

Modified: trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml	2010-08-25 14:25:35 UTC (rev 18971)
+++ trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml	2010-08-25 18:43:39 UTC (rev 18972)
@@ -23,9 +23,13 @@
 			<span id="#{clientId}:label" class="rf-ii-lbl">
 				#{inplaceValue}
 			</span>
+			<input id="#{clientId}:focus" type="image" style="position: absolute; top: 0px; left: 0px; outline-style: none;" class="rf-ii-none"/>
 			<span id="#{clientId}:edit" class="#{getEditStyleClass(component, inplaceState)}">
-				<input id="#{clientId}:input" autocomplete="off" name="#{clientId}:input" type="text" value="#{inplaceValue}" class="rf-ii-f" cdk:passThrough="tabIndex" style="width: #{component.attributes['inputWidth']};" />
-				
+				<input id="#{clientId}:input" autocomplete="off" name="#{clientId}:input" 
+					   type="text" value="#{inplaceValue}" class="rf-ii-f" style="width: #{component.attributes['inputWidth']};" 
+					   cdk:passThrough="tabIndex">
+					    <cdk:call expression="renderInputHandlers(facesContext, component);"/>
+				</input>
 				<c:if test="#{component.attributes['showControls']}">
 					<span class="rf-ii-btn-prepos">
 						<span class="rf-ii-btn-pos">



More information about the richfaces-svn-commits mailing list