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/07/14 17:47:07 UTC

svn commit: r793948 - in /wicket/trunk/wicket/src/main/java/org/apache/wicket: ajax/form/AjaxFormSubmitBehavior.java util/tester/BaseWicketTester.java

Author: jdonnerstag
Date: Tue Jul 14 15:47:07 2009
New Revision: 793948

URL: http://svn.apache.org/viewvc?rev=793948&view=rev
Log:
fixed: Two minor quick-to-fix quality bugs in WicketTester
Issue: WICKET-2363

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java?rev=793948&r1=793947&r2=793948&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java Tue Jul 14 15:47:07 2009
@@ -25,7 +25,7 @@
 import org.apache.wicket.util.string.AppendingStringBuffer;
 
 /**
- * Ajax event behavior that submits a form via ajax when the event it is attached to is invoked.
+ * Ajax event behavior that submits a form via ajax when the event it is attached to, is invoked.
  * <p>
  * The form must have an id attribute in the markup or have MarkupIdSetter added.
  * 
@@ -34,14 +34,13 @@
  * @since 1.2
  * 
  * @author Igor Vaynberg (ivaynberg)
- * 
  */
 public abstract class AjaxFormSubmitBehavior extends AjaxEventBehavior
 {
 	private static final long serialVersionUID = 1L;
 
 	/**
-	 * should never be accessed directly (thus the __ cause its overkil to create a super class),
+	 * should never be accessed directly (thus the __ cause its overkill to create a super class),
 	 * instead always use #getForm()
 	 */
 	private Form<?> __form;
@@ -81,7 +80,7 @@
 	 * 
 	 * @return Form that will be submitted by this behavior
 	 */
-	protected Form<?> getForm()
+	public final Form<?> getForm()
 	{
 		if (__form == null)
 		{

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=793948&r1=793947&r2=793948&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Tue Jul 14 15:47:07 2009
@@ -1177,7 +1177,7 @@
 	 *            the event to simulate being fired. If <code>event</code> is <code>null</code>, the
 	 *            test will fail.
 	 */
-	public void executeAjaxEvent(Component component, String event)
+	public void executeAjaxEvent(final Component component, final String event)
 	{
 		setCreateAjaxRequest(true);
 
@@ -1187,6 +1187,12 @@
 		failMessage = "event must not be null";
 		notNull(failMessage, event);
 
+		if (component.isVisibleInHierarchy() == false)
+		{
+			fail("The component is currently not visible in the hierarchy and thus you can not fire events on it." +
+				" Component: " + component + "; Event: " + event);
+		}
+
 		// Run through all the behavior and select the LAST ADDED behavior which
 		// matches the event parameter.
 		AjaxEventBehavior ajaxEventBehavior = null;
@@ -1313,20 +1319,8 @@
 	private void submitAjaxFormSubmitBehavior(final Component component,
 		AjaxFormSubmitBehavior behavior)
 	{
-		// We need to get the form submitted, using reflection.
-		// It needs to be "submitted".
-		Form<?> form = null;
-		try
-		{
-			Field formField = AjaxFormSubmitBehavior.class.getDeclaredField("__form");
-			formField.setAccessible(true);
-			form = (Form<?>)formField.get(behavior);
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		// The form that needs to be "submitted".
+		Form<?> form = behavior.getForm();
 
 		String failMessage = "No form attached to the submitlink.";
 		notNull(failMessage, form);