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

svn commit: r597130 - in /wicket/trunk/jdk-1.4/wicket/src: main/java/org/apache/wicket/ main/java/org/apache/wicket/markup/html/form/validation/ test/java/org/apache/wicket/markup/html/form/feedback/

Author: jcompagner
Date: Wed Nov 21 08:11:33 2007
New Revision: 597130

URL: http://svn.apache.org/viewvc?rev=597130&view=rev
Log:
fix for WICKET-1172
Added unit test for FeedbackBorder and FeedbackIndicator

Added:
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result1.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result2.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result1.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result2.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FormFeedbackTest.java
Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?rev=597130&r1=597129&r2=597130&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java Wed Nov 21 08:11:33 2007
@@ -987,7 +987,8 @@
 
 	private final void internalBeforeRender()
 	{
-		if (isVisible() && !getFlag(FLAG_RENDERING) && !getFlag(FLAG_PREPARED_FOR_RENDER))
+		if ((isVisible() || callOnBeforeRenderIfNotVisible()) && !getFlag(FLAG_RENDERING) &&
+			!getFlag(FLAG_PREPARED_FOR_RENDER))
 		{
 			setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);
 
@@ -3596,12 +3597,28 @@
 	 * Because this method is responsible for cascading {@link #onBeforeRender()} call to its
 	 * children it is strongly recommended that super call is made at the end of the override.
 	 * </p>
+	 * 
+	 * @see Component#callOnBeforeRenderIfNotVisible()
 	 */
 	protected void onBeforeRender()
 	{
 		setFlag(FLAG_PREPARED_FOR_RENDER, true);
 		onBeforeRenderChildren();
 		setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, true);
+	}
+
+	/**
+	 * Override this method if you want onBeforeRender to be called even when your component is not
+	 * visible. default this returns false.
+	 * 
+	 * @return boolean, if true then onBeforeRender is called even for none visible components,
+	 *         default false.
+	 * 
+	 * @see Component#onBeforeRender()
+	 */
+	protected boolean callOnBeforeRenderIfNotVisible()
+	{
+		return false;
 	}
 
 	/**

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java?rev=597130&r1=597129&r2=597130&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java Wed Nov 21 08:11:33 2007
@@ -78,6 +78,11 @@
 		setVisible(Session.get().getFeedbackMessages().hasMessage(getFeedbackMessageFilter()));
 	}
 
+	protected boolean callOnBeforeRenderIfNotVisible()
+	{
+		return true;
+	}
+
 	/**
 	 * @return Let subclass specify some other filter
 	 */

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,9 @@
+<html>
+<body>
+<form wicket:id="form">
+<span wicket:id = "feedback">
+	<input type="text" wicket:id="input">
+</span>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.java?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage.java Wed Nov 21 08:11:33 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.feedback;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
+import org.apache.wicket.model.Model;
+
+/**
+ * @author jcompagner
+ */
+public class FeedbackFormPage extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 */
+	public FeedbackFormPage()
+	{
+		final TextField tf = new TextField("input", new Model());
+		final FormComponentFeedbackBorder feedback = new FormComponentFeedbackBorder("feedback");
+		feedback.add(tf);
+
+		Form form = new Form("form")
+		{
+			private static final long serialVersionUID = 1L;
+
+			protected void onSubmit()
+			{
+				tf.error("an error");
+			}
+		};
+		form.add(feedback);
+		add(form);
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result1.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result1.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result1.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,12 @@
+<html>
+<body>
+<form action="?wicket:interface=:0:form::IFormSubmitListener::" wicket:id="form" method="post" id="form1"><div style="display:none"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+<span wicket:id="feedback"><wicket:border>
+		<wicket:body>
+	<input value="" type="text" wicket:id="input" name="feedback:input">
+</wicket:body>
+	    
+	</wicket:border></span>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result2.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result2.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result2.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackFormPage_result2.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,12 @@
+<html>
+<body>
+<form action="?wicket:interface=:0:form::IFormSubmitListener::" wicket:id="form" method="post" id="form1"><div style="display:none"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+<span wicket:id="feedback"><wicket:border>
+		<wicket:body>
+	<input value="" type="text" wicket:id="input" name="feedback:input">
+</wicket:body>
+	    <span wicket:id="errorIndicator"><span style="color:red;">*</span></span>
+	</wicket:border></span>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,8 @@
+<html>
+<body>
+<form wicket:id="form">
+	<input type="text" wicket:id="input">
+<span wicket:id = "feedback"></span>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.java?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage.java Wed Nov 21 08:11:33 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.feedback;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackIndicator;
+import org.apache.wicket.model.Model;
+
+/**
+ * @author jcompagner
+ */
+public class FeedbackIndicatorFormPage extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 */
+	public FeedbackIndicatorFormPage()
+	{
+		final TextField tf = new TextField("input", new Model());
+		final FormComponentFeedbackIndicator feedback = new FormComponentFeedbackIndicator(
+			"feedback");
+
+		Form form = new Form("form")
+		{
+			private static final long serialVersionUID = 1L;
+
+			protected void onSubmit()
+			{
+				tf.error("an error");
+			}
+		};
+		form.add(feedback);
+		form.add(tf);
+
+		add(form);
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result1.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result1.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result1.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,8 @@
+<html>
+<body>
+<form action="?wicket:interface=:0:form::IFormSubmitListener::" wicket:id="form" method="post" id="form1"><div style="display:none"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+	<input value="" type="text" wicket:id="input" name="input">
+
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result2.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result2.html?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result2.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FeedbackIndicatorFormPage_result2.html Wed Nov 21 08:11:33 2007
@@ -0,0 +1,8 @@
+<html>
+<body>
+<form action="?wicket:interface=:0:form:1:IFormSubmitListener::" wicket:id="form" method="post" id="form1"><div style="display:none"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+	<input value="" type="text" wicket:id="input" name="input">
+<span wicket:id="feedback"><wicket:panel><span style="color:red;">*</span></wicket:panel></span>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FormFeedbackTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FormFeedbackTest.java?rev=597130&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FormFeedbackTest.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/feedback/FormFeedbackTest.java Wed Nov 21 08:11:33 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.feedback;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.WicketTestCase;
+
+/**
+ * @author jcompagner
+ */
+public class FormFeedbackTest extends WicketTestCase
+{
+
+	/**
+	 * Construct.
+	 */
+	public FormFeedbackTest()
+	{
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param name
+	 */
+	public FormFeedbackTest(String name)
+	{
+		super(name);
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void testFormComponentFeedbackBorder() throws Exception
+	{
+		Page page = tester.startPage(FeedbackFormPage.class);
+		tester.assertRenderedPage(FeedbackFormPage.class);
+		tester.assertResultPage(getClass(), "FeedbackFormPage_result1.html");
+		tester.executeListener(page.get("form"));
+		tester.assertRenderedPage(FeedbackFormPage.class);
+		tester.assertResultPage(getClass(), "FeedbackFormPage_result2.html");
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void testFormComponentFeedbackIndicator() throws Exception
+	{
+		Page page = tester.startPage(FeedbackIndicatorFormPage.class);
+		tester.assertRenderedPage(FeedbackIndicatorFormPage.class);
+		tester.assertResultPage(getClass(), "FeedbackIndicatorFormPage_result1.html");
+		tester.executeListener(page.get("form"));
+		tester.assertRenderedPage(FeedbackIndicatorFormPage.class);
+		tester.assertResultPage(getClass(), "FeedbackIndicatorFormPage_result2.html");
+	}
+
+}