[richfaces-svn-commits] JBoss Rich Faces SVN: r14024 - in trunk/ui/componentControl/src/main: java/org/richfaces/component and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue May 5 13:33:03 EDT 2009


Author: nbelaevski
Date: 2009-05-05 13:33:02 -0400 (Tue, 05 May 2009)
New Revision: 14024

Modified:
   trunk/ui/componentControl/src/main/config/component/componentControl.xml
   trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
Log:
https://jira.jboss.org/jira/browse/RF-6275

Modified: trunk/ui/componentControl/src/main/config/component/componentControl.xml
===================================================================
--- trunk/ui/componentControl/src/main/config/component/componentControl.xml	2009-05-05 16:29:40 UTC (rev 14023)
+++ trunk/ui/componentControl/src/main/config/component/componentControl.xml	2009-05-05 17:33:02 UTC (rev 14024)
@@ -37,6 +37,7 @@
 			<description>
 				Disable default action for target event ( append &quot;return false;&quot; to JavaScript )
 			</description>
+			<!-- Has a special dynamic default value -->
 		</property>
 		<property>
 			<name>event</name>

Modified: trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
--- trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java	2009-05-05 16:29:40 UTC (rev 14023)
+++ trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java	2009-05-05 17:33:02 UTC (rev 14024)
@@ -21,7 +21,9 @@
 
 package org.richfaces.component;
 
+import javax.el.ELException;
 import javax.el.ValueExpression;
+import javax.faces.FacesException;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIComponentBase;
 import javax.faces.component.UIParameter;
@@ -51,6 +53,9 @@
     
     private static final Log log = LogFactory.getLog(UIComponentControl.class);
     
+    private boolean disableDefault = false;
+    private boolean disableDefaultSet = false;
+    
     /**
      * @return JavaScript eventString. Rebuild on every call, since can be in
      *         loop ( as in dataTable ) with different parameters.
@@ -137,6 +142,35 @@
     
     public abstract void setAttachTo(String value);
     
+    public boolean isDisableDefault() {
+    	if (this.disableDefaultSet) {
+    	    return (this.disableDefault);
+    	}
+    	
+    	ValueExpression ve = getValueExpression("disableDefault");
+    	if (ve != null) {
+    	    Boolean value = null;
+    	    
+    	    try {
+    			value = (Boolean) ve.getValue(getFacesContext().getELContext());
+    	    } catch (ELException e) {
+    			throw new FacesException(e);
+    	    }
+    	    
+    	    if (null != value) {
+        	    return value.booleanValue();
+    	    }
+    	}
+
+    	String event = getEvent();
+	    return ("contextmenu".equalsIgnoreCase(event) || "oncontextmenu".equalsIgnoreCase(event));
+    }
+
+    public void setDisableDefault(boolean disableDefault) {
+    	this.disableDefaultSet = true;
+    	this.disableDefault = disableDefault;
+    }
+    
     protected String replaceClientIds(FacesContext context,
             UIComponent component, String selector) {
         return HtmlUtil.expandIdSelector(selector, component, context);
@@ -197,4 +231,22 @@
     public abstract void setAttachTiming(String attachTiming);
     
     public abstract String getAttachTiming();
+    
+    @Override
+    public Object saveState(FacesContext context) {
+    	Object[] state = new Object[3];
+    	state[0] = super.saveState(context);
+    	state[1] = this.disableDefault ? Boolean.TRUE : Boolean.FALSE;
+    	state[2] = this.disableDefaultSet ? Boolean.TRUE : Boolean.FALSE;
+
+    	return state;
+    }
+    
+    @Override
+    public void restoreState(FacesContext context, Object stateObject) {
+    	Object[] state = (Object[]) stateObject;
+    	super.restoreState(context, state[0]);
+    	this.disableDefault = ((Boolean) state[1]).booleanValue();
+    	this.disableDefaultSet = ((Boolean) state[2]).booleanValue();
+    }
 }




More information about the richfaces-svn-commits mailing list