[richfaces-svn-commits] JBoss Rich Faces SVN: r5383 - in trunk/ui/tooltip/src/main: java/org/richfaces and 4 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jan 15 10:06:31 EST 2008


Author: akushunin
Date: 2008-01-15 10:06:31 -0500 (Tue, 15 Jan 2008)
New Revision: 5383

Added:
   trunk/ui/tooltip/src/main/java/org/richfaces/taglib/
   trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagBase.java
   trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagHandlerBase.java
Modified:
   trunk/ui/tooltip/src/main/config/component/toolTip.xml
   trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java
   trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
   trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
RF-1900

Modified: trunk/ui/tooltip/src/main/config/component/toolTip.xml
===================================================================
--- trunk/ui/tooltip/src/main/config/component/toolTip.xml	2008-01-15 14:27:47 UTC (rev 5382)
+++ trunk/ui/tooltip/src/main/config/component/toolTip.xml	2008-01-15 15:06:31 UTC (rev 5383)
@@ -27,13 +27,17 @@
 
 		<tag>
 			<name>toolTip</name>
-			<classname>org.richfaces.taglib.HtmlToolTipTag</classname>
-			<superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
+			<classname>org.richfaces.taglib.ToolTipTag</classname>
+			<superclass>org.richfaces.taglib.ToolTipTagBase</superclass>
 			<test>
 				<classname>org.richfaces.taglib.HtmlToolTipTagTest</classname>
 				<superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
 			</test>
 		</tag>
+		<taghandler generate="true">
+			<classname>org.richfaces.taglib.HtmlToolTipTagHandler</classname>
+			<superclass>org.richfaces.taglib.ToolTipTagHandlerBase</superclass>
+		</taghandler>
 
 	    <property>
 	    	<name>layout</name>
@@ -94,12 +98,6 @@
 	    	<defaultvalue><![CDATA[""]]></defaultvalue>
 	    </property> 
 	    <property>
-	    	<name>event</name>
-	    	<classname>java.lang.String</classname>
-	    	<description>event that triggers the tooltip appearance (default = onmouseover)</description>
-	    	<defaultvalue><![CDATA["mouseover"]]></defaultvalue>
-	    </property> 
-	    <property>
 	    	<name>mode</name>
 	    	<classname>java.lang.String</classname>
 	    	<description>controls the way of data loading to tooltip and should have following values client (default), ajax</description>
@@ -181,6 +179,18 @@
 	    	<description>HTML: a script expression; a pointer is moved onto</description>
 	    	<defaultvalue><![CDATA[""]]></defaultvalue>
 	    </property> 
+	    <property exist="true" existintag="true">
+	    	<name>showEvent</name>
+	    	<classname>java.lang.String</classname>
+	    	<description>Event that triggers the tooltip appearance (default = onmouseover)</description>
+	    	<defaultvalue><![CDATA["mouseover"]]></defaultvalue>
+	    </property> 
+	    <property>
+	    	<name>hideEvent</name>
+	    	<classname>java.lang.String</classname>
+	    	<description>Event that triggers the tooltip disappearance</description>
+	    	<defaultvalue><![CDATA[""]]></defaultvalue>	    	
+	    </property> 
 	</component>
 	<renderer generate="true">
 		<template>org/richfaces/htmltooltipblock.jspx</template>

Modified: trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java	2008-01-15 14:27:47 UTC (rev 5382)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java	2008-01-15 15:06:31 UTC (rev 5383)
@@ -109,6 +109,15 @@
 	
 	public abstract void setFor(String _for);
 	
+	public abstract String getShowEvent();
+	
+	public abstract void setShowEvent(String showEvent);
+	
+	public abstract String getHideEvent();
+	
+	public abstract void setHideEvent(String hideEvent);
+	
+	
 	public String getUsedElementType(){
 		return getLayout().equals("block") ? "div" : "span";
 	}

Modified: trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2008-01-15 14:27:47 UTC (rev 5382)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2008-01-15 15:06:31 UTC (rev 5383)
@@ -164,7 +164,7 @@
         } else {
 			JSFunctionDefinition onComplete = new JSFunctionDefinition();
 			onComplete.addParameter("request");
-			onComplete.addParameter("event");
+			onComplete.addParameter("showEvent");
 			onComplete.addParameter("data");
 			onComplete.addToBody(oncompleteTooltip);
 			eventOptions.put("oncomplete", onComplete);
@@ -177,7 +177,7 @@
         } else {
 			JSFunctionDefinition beforeUpdate = new JSFunctionDefinition();
 			beforeUpdate.addParameter("request");
-			beforeUpdate.addParameter("event");
+			beforeUpdate.addParameter("showEvent");
 			beforeUpdate.addParameter("data");
 			beforeUpdate.addToBody(fireBeforeUpdateDOM);
 			eventOptions.put(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME, beforeUpdate);
@@ -232,13 +232,18 @@
 		StringBuffer ret = new StringBuffer();
 		String comma = ",";
 		String quot = "\"";
-		String event = toolTip.getEvent();
-		if(event.startsWith("on")){
-			event = event.substring(2);
+		String eventS = toolTip.getShowEvent();
+		String eventH = toolTip.getHideEvent();
+		if(eventS.startsWith("on")){
+			eventS = eventS.substring(2);
 		}
+		if(eventH.startsWith("on")){
+			eventH = eventH.substring(2);
+		}
 		
 		Map eventsMap = new HashMap();
-		eventsMap.put(new JSReference("event"), event);
+		eventsMap.put(new JSReference("showEvent"), eventS);
+		eventsMap.put(new JSReference("hideEvent"), eventH);
 		eventsMap.put(new JSReference("delay"), new Integer(toolTip.getShowDelay()));
 		eventsMap.put(new JSReference("hideDelay"), new Integer(toolTip.getHideDelay()));
 		

Added: trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagBase.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagBase.java	                        (rev 0)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagBase.java	2008-01-15 15:06:31 UTC (rev 5383)
@@ -0,0 +1,68 @@
+package org.richfaces.taglib;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.webapp.taglib.HtmlComponentTagBase;
+import org.richfaces.component.UIToolTip;
+
+/**
+ * Created 23.08.2007
+ * @author Alexej Kushunin
+ * @since 3.2
+ */
+public abstract class ToolTipTagBase extends HtmlComponentTagBase {
+
+	private boolean _showEventSet = false;
+	private ValueExpression _event = null;
+
+	private void logValueDeprecation(ValueExpression event) {
+		FacesContext facesContext = getFacesContext();
+		facesContext.getExternalContext().log("showEvent attribute has been already set for component with id: " + this.getId() + 
+				"[" + event.getExpressionString() + "]. event attribute is deprecated and thus has been dropped!");
+	}
+	
+	public void setShowEvent(ValueExpression event) {
+		if (!_showEventSet && _event != null) {
+			logValueDeprecation(event);
+		}
+		
+		_event = event;
+		_showEventSet = true;
+	}
+	
+	public void setEvent(ValueExpression event) {
+		if (!_showEventSet) {
+			_event = event;
+		} else {
+			logValueDeprecation(_event);
+		}
+	}
+
+	protected void setProperties(UIComponent component) {
+		super.setProperties(component);
+
+		if (_event != null) {
+			if (_event.isLiteralText()) {
+				UIToolTip toolTip = (UIToolTip) component;
+				try {
+					toolTip.setShowEvent(_event.getExpressionString());
+				} catch (ELException e) {
+					throw new FacesException(e);
+				}
+			} else {
+				component.setValueExpression("showEvent", _event);
+			}
+		}
+	}
+	
+	public void release() {
+		super.release();
+		_showEventSet = false;
+		_event = null;
+	}
+
+}


Property changes on: trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagBase.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagHandlerBase.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagHandlerBase.java	                        (rev 0)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagHandlerBase.java	2008-01-15 15:06:31 UTC (rev 5383)
@@ -0,0 +1,32 @@
+package org.richfaces.taglib;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.webapp.taglib.AjaxComponentHandler;
+
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributes;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+
+public abstract class ToolTipTagHandlerBase extends AjaxComponentHandler {
+	
+	public ToolTipTagHandlerBase(ComponentConfig config) {
+		super(config);
+	}
+		
+	protected MetaRuleset createMetaRuleset(Class type) {
+		TagAttributes attributes = this.tag.getAttributes();
+		TagAttribute attribute = attributes.get("event");
+		if (attribute != null && attributes.get("showEvent") != null) {
+			TagAttribute idAttribute = attributes.get("id");
+			FacesContext facesContext = FacesContext.getCurrentInstance();
+			facesContext.getExternalContext().log("showEvent attribute has been already set for component with id: " + 
+					idAttribute != null ? idAttribute.getValue() : null + 
+					"[" + attribute.getValue() + "]. event attribute is deprecated and thus has been dropped!");
+		}
+		return super.createMetaRuleset(type).alias("showEvent", "event");
+	}
+
+	
+}


Property changes on: trunk/ui/tooltip/src/main/java/org/richfaces/taglib/ToolTipTagHandlerBase.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
--- trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2008-01-15 14:27:47 UTC (rev 5382)
+++ trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2008-01-15 15:06:31 UTC (rev 5383)
@@ -8,7 +8,8 @@
 	initialize:function(events,functions, id, parentId, mode, disabled, direction, followMouse, horizontalOffset, verticalOffset, ajaxFunction, ajaxOptions){
 		this["rich:destructor"] = "destroy";
 		
-		this.event = events.event;		
+		this.showEvent = events.showEvent;		
+		this.hideEvent = events.hideEvent!=""?events.hideEvent:null;
 		this.onshow = functions.onshow; 
 		this.oncomplete = functions.oncomplete;
 		this.onhide = functions.onhide;
@@ -104,11 +105,21 @@
 						
 				Event.stopObserving(this.parent, this.event, this.customEventHandlerListner, false);
 				
-				if (this.event != "focus") {
-					Event.stopObserving(this.parent, "mouseout", this.doHideListner, false);
-					Event.stopObserving(this.toolTip, "mouseout", this.leaveToolTipListner, false);
-				} else {
-					Event.stopObserving(this.parent, "blur", this.doHideListner, false);
+				if (this.showEvent != "focus") {
+					if(this.hideEvent != null){
+						Event.stopObserving(this.parent, this.hideEvent, this.doHideListner, false);
+						Event.stopObserving(this.toolTip, this.hideEvent, this.leaveToolTipListner, false);
+					}else{
+						Event.stopObserving(this.parent, "mouseout", this.doHideListner, false);
+						Event.stopObserving(this.toolTip,"mouseout", this.leaveToolTipListner, false);
+					}
+					
+				} else{
+					if(this.hideEvent != null){
+						Event.stopObserving(this.parent, this.hideEvent, this.doHideListner, false);
+					}else{
+						Event.stopObserving(this.parent, "blur", this.doHideListner, false);
+					}
 				}
 			}
 
@@ -119,7 +130,8 @@
 			this.toolTipDefaultContent = null;
 			this.iframe = null;
 			this.eventCopy = null;
-			this.event = null;
+			this.showEvent = null;
+			this.hideEvent = null;
 	},
 	
 	attachOnLoadEvents: function(){
@@ -169,13 +181,23 @@
 			this.customEventHandlerListner = this.doShow.bindAsEventListener(this);
 		}
 
-		Event.observe(this.parent, this.event, this.customEventHandlerListner, false);
-		
-		if (this.event != "focus") {
-			Event.observe(this.parent, "mouseout", this.doHideListner, false);
-			Event.observe(this.toolTip, "mouseout", this.leaveToolTipListner, false);
+		Event.observe(this.parent, this.showEvent, this.customEventHandlerListner, false);
+		//TODO handle onfocus and onblur show/hide events
+		if (this.showEvent != "focus") {
+			if(this.hideEvent != null){
+				Event.observe(this.parent, this.hideEvent, this.doHideListner, false);
+				Event.observe(this.toolTip, this.hideEvent, this.leaveToolTipListner, false);
+			}else{
+				Event.observe(this.parent, "mouseout", this.doHideListner, false);
+				Event.observe(this.toolTip, "mouseout", this.leaveToolTipListner, false);			
+			}
+			
 		} else {
-			Event.observe(this.parent, "blur", this.doHideListner, false);
+			if(this.hideEvent != null){
+				Event.observe(this.parent, this.hideEvent, this.doHideListner, false);
+			}else{
+				Event.observe(this.parent, "blur", this.doHideListner, false);
+			}			
 		}
 	},
 	




More information about the richfaces-svn-commits mailing list