[richfaces-svn-commits] JBoss Rich Faces SVN: r2129 - trunk/ui/core/src/main/java/org/ajax4jsf/component.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 7 20:14:58 EDT 2007


Author: alexsmirnov
Date: 2007-08-07 20:14:58 -0400 (Tue, 07 Aug 2007)
New Revision: 2129

Modified:
   trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
Log:
Check for a null value of the "event" attribute

Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java	2007-08-08 00:10:27 UTC (rev 2128)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java	2007-08-08 00:14:58 UTC (rev 2129)
@@ -31,139 +31,156 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-
 /**
- * Component for append ajax functions to any control component.
- * Append action functionality to non-action control,
- * setup javascript events for parent component,
+ * Component for append ajax functions to any control component. Append action
+ * functionality to non-action control, setup javascript events for parent
+ * component,
+ * 
  * @author shura (latest modification by $Author: alexsmirnov $)
  * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
- *
+ * 
  */
-public abstract class UIAjaxSupport extends AjaxActionComponent implements  AjaxSupport
-{
+public abstract class UIAjaxSupport extends AjaxActionComponent implements
+		AjaxSupport {
 
-    //~ Static fields/initializers ---------------------------------------------
+	// ~ Static fields/initializers
+	// ---------------------------------------------
 
-    public static final String COMPONENT_TYPE = "org.ajax4jsf.Support";
-    public static final String COMPONENT_FAMILY = "org.ajax4jsf.AjaxSupport";
-    public static final String DEFAULT_RENDERER_TYPE = "org.ajax4jsf.components.AjaxSupportRenderer";
-    public static final String AJAX_SUPPORT_SET = "com.exadel.components.ajax.support.";
-    private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
+	public static final String COMPONENT_TYPE = "org.ajax4jsf.Support";
+	public static final String COMPONENT_FAMILY = "org.ajax4jsf.AjaxSupport";
+	public static final String DEFAULT_RENDERER_TYPE = "org.ajax4jsf.components.AjaxSupportRenderer";
+	public static final String AJAX_SUPPORT_SET = "com.exadel.components.ajax.support.";
+	private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
 
-    /**
-     * Name of JavaScript function, called before submit Ajax request
+	/**
+	 * Name of JavaScript function, called before submit Ajax request
 	 * description
+	 * 
 	 * @parameter
 	 * @return the acceptClass
 	 */
 	public abstract String getOnsubmit();
 
 	/**
-	 * @param newOnsubmit the value  to set
+	 * @param newOnsubmit
+	 *            the value to set
 	 */
 	public abstract void setOnsubmit(String newOnsubmit);
-    /* (non-Javadoc)
-	 * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String, javax.faces.el.ValueBinding)
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String,
+	 *      javax.faces.el.ValueBinding)
 	 */
 	public void setValueBinding(String arg0, ValueBinding arg1) {
 		// var - not allowed name. must be literal.
-		if("var".equals(arg0)){
-			throw new FacesException(
-					Messages.getMessage(Messages.VAR_MUST_BE_LITERAL, getClientId(getFacesContext())));
+		if ("var".equals(arg0)) {
+			throw new FacesException(Messages.getMessage(
+					Messages.VAR_MUST_BE_LITERAL,
+					getClientId(getFacesContext())));
 		}
-		if("event".equals(arg0)){
-			throw new FacesException(
-					Messages.getMessage(Messages.EVENT_MUST_BE_LITERAL, getClientId(getFacesContext())));
+		if ("event".equals(arg0)) {
+			throw new FacesException(Messages.getMessage(
+					Messages.EVENT_MUST_BE_LITERAL,
+					getClientId(getFacesContext())));
 		}
 		super.setValueBinding(arg0, arg1);
 	}
 
 	/**
-     * Create Special <code>ValueBinding</code> for build JavaScrept
-     * event code in parent component from this.
-     * @return <code>EventValueBinding</code> based on properties of current component
-     */
-    private ValueBinding getEventValueBinding()
-    {
-        if (log.isDebugEnabled())
-        {
-            log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT, getId()));
-        }
-        return new EventValueBinding(this);
-    }
+	 * Create Special <code>ValueBinding</code> for build JavaScrept event
+	 * code in parent component from this.
+	 * 
+	 * @return <code>EventValueBinding</code> based on properties of current
+	 *         component
+	 */
+	private ValueBinding getEventValueBinding() {
+		if (log.isDebugEnabled()) {
+			log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT,
+					getId()));
+		}
+		return new EventValueBinding(this);
+	}
 
-    /**
-     * @return JavaScript eventString. Rebuild on every call, since
-     * can be in loop ( as in dataTable ) with different parameters.
-     */
-    public String getEventString()
-    {
-        StringBuffer buildOnEvent = new StringBuffer();
-        String onsubmit = getOnsubmit();
-        // Insert script to call before submit ajax request.
-        if (null != onsubmit) {
+	/**
+	 * @return JavaScript eventString. Rebuild on every call, since can be in
+	 *         loop ( as in dataTable ) with different parameters.
+	 */
+	public String getEventString() {
+		StringBuffer buildOnEvent = new StringBuffer();
+		String onsubmit = getOnsubmit();
+		// Insert script to call before submit ajax request.
+		if (null != onsubmit) {
 			buildOnEvent.append(onsubmit).append(";");
 		}
-        // Due to JSF RI 1.1 bug, clear cached clientId
-        setId(getId());
-		buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
-				                getEvent()));
+		// Due to JSF RI 1.1 bug, clear cached clientId
+		setId(getId());
+		buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
+				getFacesContext(), getEvent()));
 		String script = buildOnEvent.toString();
 		return script;
-    }
+	}
 
-    /* (non-Javadoc)
-     * @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
-     */
-    public void decode(FacesContext context) {
-        // Due to JSF RI 1.1 bug, clear cached clientId
-        setId(getId());
-    	super.decode(context);
-    }
-    
-    /**
-     * After nornal setting <code>parent</code> property in case of
-     * created component set Ajax properties for parent.
-     * @see javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
-     */
-    public void setParent(UIComponent parent)
-    {
-        super.setParent(parent);
-        if (null != parent && parent.getFamily() != null ) {
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
+	 */
+	public void decode(FacesContext context) {
+		// Due to JSF RI 1.1 bug, clear cached clientId
+		setId(getId());
+		super.decode(context);
+	}
+
+	/**
+	 * After nornal setting <code>parent</code> property in case of created
+	 * component set Ajax properties for parent.
+	 * 
+	 * @see javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+	 */
+	public void setParent(UIComponent parent) {
+		super.setParent(parent);
+		if (null != parent && parent.getFamily() != null) {
 			if (log.isDebugEnabled()) {
-				log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT, parent.getClass().getName()));
+				log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
+						parent.getClass().getName()));
 			}
-			// TODO If this comopnent configured, set properties for parent component.
-			// NEW created component have parent, restored view - null in My faces.
-			// and SUN RI not call at restore saved view. 
+			// TODO If this comopnent configured, set properties for parent
+			// component.
+			// NEW created component have parent, restored view - null in My
+			// faces.
+			// and SUN RI not call at restore saved view.
 			// In other case - set in restoreState method.
-			//        if (parent.getParent() != null)
+			// if (parent.getParent() != null)
 			{
 				if (log.isDebugEnabled()) {
-					log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
+					log.debug(Messages
+							.getMessage(Messages.DETECT_NEW_COMPONENT));
 				}
 				setParentProperties(parent);
 
 			}
 		}
-    }
+	}
 
-    public void setParentProperties(UIComponent parent) {
-        ValueBinding valueBinding;
-            if (log.isDebugEnabled())
-            {
-                log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT, getEvent()));
-            }
-            // for non action/data components, or for non-default events - build listener for this instance. 
-            valueBinding = getEventValueBinding();
-            // test for valid event attribute name.
-            // TODO - test for compability with concrete element.
-            parent.setValueBinding(getEvent(), valueBinding);
-    }
-    
-    protected UIComponent getSingleComponent() {
-        return getParent();
-    }
+	public void setParentProperties(UIComponent parent) {
+		ValueBinding valueBinding;
+		if (null != getEvent()) {
+			if (log.isDebugEnabled()) {
+				log.debug(Messages.getMessage(
+						Messages.SET_VALUE_BINDING_FOR_EVENT, getEvent()));
+			}
+			// for non action/data components, or for non-default events - build
+			// listener for this instance.
+			valueBinding = getEventValueBinding();
+			parent.setValueBinding(getEvent(), valueBinding);
 
+		}
+	}
+
+	protected UIComponent getSingleComponent() {
+		return getParent();
+	}
+
 }




More information about the richfaces-svn-commits mailing list