You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2007/04/19 19:09:17 UTC

svn commit: r530489 - /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java

Author: knopp
Date: Thu Apr 19 10:09:15 2007
New Revision: 530489

URL: http://svn.apache.org/viewvc?view=rev&rev=530489
Log:
allow to disable setting focus after ajax request

Modified:
    incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java

Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?view=diff&rev=530489&r1=530488&r2=530489
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java Thu Apr 19 10:09:15 2007
@@ -347,24 +347,21 @@
 
 	/**
 	 * Sets the focus in the browser to the given component. The markup id must
-	 * be set.
+	 * be set. If the component is null the focus will not be set to any component.
 	 * 
 	 * @param component
-	 *            The component to get the focus.
+	 *            The component to get the focus or null.
 	 */
 	public final void focusComponent(Component component)
 	{
-		if (component == null)
-		{
-			throw new IllegalArgumentException("component cannot be null");
-		}
-		if (component.getOutputMarkupId() == false)
+		if (component != null && component.getOutputMarkupId() == false)
 		{
 			throw new IllegalArgumentException(
 					"cannot update component that does not have setOutputMarkupId property set to true. Component: "
 							+ component.toString());
 		}
-		appendJavascript("Wicket.Focus.setFocusOnId('" + component.getMarkupId() + "');");
+		final String id = component != null ? component.getMarkupId() : null;
+		appendJavascript("Wicket.Focus.setFocusOnId('" + null + "');");
 	}