You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2009/09/26 08:59:46 UTC

svn commit: r819096 - /wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java

Author: jdonnerstag
Date: Sat Sep 26 06:59:45 2009
New Revision: 819096

URL: http://svn.apache.org/viewvc?rev=819096&view=rev
Log:
fixed: need to know if a component has been added to the AjaxRequestTarget
Issue: WICKET-2489

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?rev=819096&r1=819095&r2=819096&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java Sat Sep 26 06:59:45 2009
@@ -221,7 +221,6 @@
 				buffer.append(cs);
 			}
 		}
-
 	}
 
 	private static final Logger LOG = LoggerFactory.getLogger(AjaxRequestTarget.class);
@@ -245,11 +244,16 @@
 	/** the component instances that will be rendered */
 	private final Map<String, Component> markupIdToComponent = new LinkedHashMap<String, Component>();
 
+	/** */
 	private final List<String> prependJavascripts = new ArrayList<String>();
 
 	/** a list of listeners */
 	private List<IListener> listeners = null;
 
+	/** */
+	private final Set<ITargetRespondListener> respondListeners = new HashSet<ITargetRespondListener>();
+
+	/** The associated Page */
 	private final Page page;
 
 	/**
@@ -387,6 +391,17 @@
 	}
 
 	/**
+	 * Return true, if the Component has already been added
+	 * 
+	 * @param component
+	 * @return true, if already added
+	 */
+	public final boolean isAdded(final Component component)
+	{
+		return (null != markupIdToComponent.get(component.getMarkupId()));
+	}
+
+	/**
 	 * Sets the focus in the browser to the given component. The markup id must be set. If the
 	 * component is null the focus will not be set to any component.
 	 * 
@@ -498,8 +513,6 @@
 		public void onTargetRespond(AjaxRequestTarget target);
 	};
 
-	private final Set<ITargetRespondListener> respondListeners = new HashSet<ITargetRespondListener>();
-
 	/**
 	 * Register the given respond listener. The listener's
 	 * {@link ITargetRespondListener#onTargetRespond(AjaxRequestTarget)} method will be invoked when
@@ -618,7 +631,6 @@
 			// javascript
 			final IJavascriptResponse jsresponse = new IJavascriptResponse()
 			{
-
 				public void addJavascript(String script)
 				{
 					respondInvocation(response, script);
@@ -641,7 +653,6 @@
 	 */
 	private void respondComponents(WebResponse response)
 	{
-
 		// TODO: We might need to call prepareRender on all components upfront
 
 		// process component markup
@@ -838,7 +849,6 @@
 	 */
 	private class AjaxHeaderResponse extends HeaderResponse
 	{
-
 		private static final long serialVersionUID = 1L;
 
 		private void checkHeaderRendering()
@@ -925,7 +935,6 @@
 		 */
 		public AjaxHeaderResponse()
 		{
-
 		}
 
 		/**