Author: ivaynberg
Date: Tue Nov 14 00:16:36 2006
New Revision: 474693
URL: http://svn.apache.org/viewvc?view=rev&rev=474693
Log:
WICKET-64 fix check/radio when hierarchy changes
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Check.java
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Radio.java
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTest.java
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage1_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage2_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage3_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage4_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage1_expected.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage3_expected.html
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Check.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Check.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Check.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Check.java
Tue Nov 14 00:16:36 2006
@@ -47,6 +47,24 @@
private static final String ATTR_DISABLED = "disabled";
+ private short uuid = -1;
+
+ /**
+ * Form submission value used for this radio component. This string will
+ * appear as the value of the <code>value</code> html attribute for the
+ * <code>input</code> tag.
+ *
+ * @return form submission value
+ */
+ public final String getValue()
+ {
+ if (uuid < 0)
+ {
+ uuid = getPage().getAutoIndex();
+ }
+ return "check" + uuid;
+ }
+
/**
* @see WebMarkupContainer#WebMarkupContainer(MarkupContainer,String)
@@ -82,20 +100,21 @@
checkComponentTagAttribute(tag, "type", "checkbox");
CheckGroup<?> group = findParent(CheckGroup.class);
- String path = getPath();
+
if (group == null)
{
throw new WicketRuntimeException(
"Check component ["
- + path
+ + getPath()
+ "] cannot find its
parent CheckGroup. All Check components must be a child of or below in the
hierarchy of a CheckGroup component.");
}
- String relativePath = path.substring(group.getPath().length() +
1);
-
+
+ final String value = getValue();
+
// assign name and value
tag.put("name", group.getInputName());
- tag.put("value", relativePath);
+ tag.put("value", value);
// check if the model collection of the group contains the
model object.
// if it does check the check box.
@@ -112,10 +131,13 @@
if (group.hasRawInput())
{
- String rawInput = group.getRawInput();
- if (rawInput != null && rawInput.indexOf(relativePath)
!= -1)
+ String[] inputs = group.getInputAsArray();
+ for (String input : inputs)
{
- tag.put("checked", "checked");
+ if (value.equals(input))
+ {
+ tag.put("checked", "checked");
+ }
}
}
else if (collection.contains(getModelObject()))
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
Tue Nov 14 00:16:36 2006
@@ -17,12 +17,14 @@
package wicket.markup.html.form;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import wicket.Component;
import wicket.MarkupContainer;
import wicket.WicketRuntimeException;
import wicket.markup.html.WebMarkupContainer;
@@ -63,7 +65,7 @@
public class CheckGroup<T> extends FormComponent<Collection<T>> implements
IOnChangeListener
{
private static final long serialVersionUID = 1L;
-
+
/** Log. */
private static final Log log = LogFactory.getLog(CheckGroup.class);
@@ -116,7 +118,7 @@
*/
@SuppressWarnings("unchecked")
@Override
- protected Collection<T> convertValue(String[] paths) throws
ConversionException
+ protected Collection<T> convertValue(String[] values) throws
ConversionException
{
List<T> collection = new ArrayList<T>();
@@ -125,28 +127,42 @@
* collection has already been cleared
*/
- if (paths != null && paths.length > 0)
+ if (values != null && values.length > 0)
{
- for (String element : paths)
+ for (final String value : values)
{
- String path = element;
-
- if (path != null)
+ if (value != null)
{
// retrieve the selected checkbox
component
- Check<T> checkbox = (Check<T>)get(path);
+ Check<T> checkbox =
(Check)visitChildren(new Component.IVisitor()
+ {
+
+ public Object
component(Component component)
+ {
+ if (component
instanceof Check)
+ {
+ final Check
check = (Check)component;
+ if
(String.valueOf(check.getValue()).equals(value))
+ {
+ return
check;
+ }
+ }
+ return
CONTINUE_TRAVERSAL;
+ }
+
+ });
if (checkbox == null)
{
throw new
WicketRuntimeException(
"submitted http
post value ["
-
+ paths.toString()
+
+ Arrays.toString(values)
+ "] for CheckGroup component ["
+ getPath()
-
+ "] contains an illegal relative path "
-
+ "element ["
-
+ path
+
+ "] contains an illegal value "
+
+ "["
+
+ value
+ "] which does not point to a Check component. Due to this the CheckGroup
component cannot resolve the selected Check component pointed to by the illegal
value. A possible reason is that componment hierarchy changed between rendering
and form submission.");
}
@@ -180,10 +196,10 @@
try
{
getModel().setObject(collection);
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
- // ignore this exception because it could be
that there
+ // ignore this exception because it could be
that there
// is not setter for this collection.
log.info("no setter for the property attached
to " + this);
}
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Radio.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Radio.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Radio.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/Radio.java
Tue Nov 14 00:16:36 2006
@@ -47,6 +47,28 @@
*/
private static final long serialVersionUID = 1L;
+ /**
+ * page-scoped uuid of this check. this property must not be accessed
+ * directly, instead [EMAIL PROTECTED] #getValue()} must be used
+ */
+ private short uuid = -1;
+
+ /**
+ * Form submission value used for this radio component. This string will
+ * appear as the value of the <code>value</code> html attribute for the
+ * <code>input</code> tag.
+ *
+ * @return form submission value
+ */
+ public final String getValue()
+ {
+ if (uuid < 0)
+ {
+ uuid = getPage().getAutoIndex();
+ }
+ return "radio" + uuid;
+ }
+
/**
* @see WebMarkupContainer#WebMarkupContainer(MarkupContainer,String)
@@ -83,28 +105,27 @@
checkComponentTagAttribute(tag, "type", "radio");
final RadioGroup group = findParent(RadioGroup.class);
- final String path = getPath();
+
+ final String value = getValue();
if (group == null)
{
throw new WicketRuntimeException(
"Radio component ["
- + path
+ + getPath()
+ "] cannot find its
parent RadioGroup. All Radio components must be a child of or below in the
hierarchy of a RadioGroup component.");
}
- final String relativePath =
path.substring(group.getPath().length() + 1);
-
// assign name and value
tag.put("name", group.getInputName());
- tag.put("value", relativePath);
+ tag.put("value", value);
// compare the model objects of the group and self, if the same
add the
// checked attribute, first check if there was a raw input on
the group.
if (group.hasRawInput())
{
String rawInput = group.getRawInput();
- if (rawInput != null && rawInput.equals(relativePath))
+ if (rawInput != null && rawInput.equals(value))
{
tag.put("checked", "checked");
}
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
Tue Nov 14 00:16:36 2006
@@ -16,6 +16,7 @@
*/
package wicket.markup.html.form;
+import wicket.Component;
import wicket.MarkupContainer;
import wicket.WicketRuntimeException;
import wicket.markup.html.WebMarkupContainer;
@@ -31,13 +32,13 @@
* ie
*
* <pre>
- * <span wicket:id="radiochoicegroup">
- * ...
- * <input type="radio"
wicket:id="singleradiochoice1">choice 1</input>
- * ...
- * <input type="radio"
wicket:id="singleradiochoice2">choice 2</input>
- * ...
- * </span>
+ * <span wicket:id="radiochoicegroup">
+ * ...
+ * <input type="radio"
wicket:id="singleradiochoice1">choice 1</input>
+ * ...
+ * <input type="radio"
wicket:id="singleradiochoice2">choice 2</input>
+ * ...
+ * </span>
* </pre>
*
* @param <T>
@@ -97,16 +98,31 @@
{
if (input != null && input.length > 0)
{
- String path = input[0];
+ final String value = input[0];
// retrieve the selected single radio choice component
- Radio<T> choice = (Radio<T>)get(path);
+ Radio<T> choice = (Radio)visitChildren(new
Component.IVisitor()
+ {
+
+ public Object component(Component component)
+ {
+ if (component instanceof Radio)
+ {
+ final Radio radio =
(Radio)component;
+ if
(radio.getValue().equals(value))
+ {
+ return radio;
+ }
+ }
+ return CONTINUE_TRAVERSAL;
+ }
+ });
if (choice == null)
{
throw new WicketRuntimeException(
"submitted http post value ["
- + path
+ + value
+ "] for
RadioGroup component ["
+ getPath()
+ "] is illegal
because it does not contain relative path to a Radio componnet. "
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
Tue Nov 14 00:16:36 2006
@@ -130,10 +130,7 @@
}
else
{
- String path = foundRadio.getPath();
- path =
path.substring(formComponent.getPath().length() + 1, path.length());
-
-
assignValueToFormComponent(formComponent, path);
+
assignValueToFormComponent(formComponent, foundRadio.getValue());
}
}
else if (formComponent instanceof CheckGroup)
@@ -146,10 +143,7 @@
+ index);
}
- String path = foundCheck.getPath();
- path =
path.substring(formComponent.getPath().length() + 1, path.length());
-
- assignValueToFormComponent(formComponent, path);
+ assignValueToFormComponent(formComponent,
foundCheck.getValue());
}
else
{
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
Tue Nov 14 00:16:36 2006
@@ -6,9 +6,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
<span name="group" disabled="disabled" wicket:id="group">
- <Input checked="checked" value="check1" type="checkbox"
name="group" disabled="disabled" wicket:id="check1">check1</input>
+ <Input checked="checked" value="check0" type="checkbox"
name="group" disabled="disabled" wicket:id="check1">check1</input>
<span wicket:id="container">
- <input checked="checked"
value="container:check2" type="checkbox" name="group" disabled="disabled"
wicket:id="check2">check2</input>
+ <input checked="checked" value="check1"
type="checkbox" name="group" disabled="disabled"
wicket:id="check2">check2</input>
</span>
</span>
</FORM>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTest.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTest.java?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTest.java
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTest.java
Tue Nov 14 00:16:36 2006
@@ -14,196 +14,196 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package wicket.markup.html.form;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import wicket.WicketRuntimeException;
-import wicket.WicketTestCase;
-import wicket.markup.html.WebMarkupContainer;
-import wicket.model.CompoundPropertyModel;
-import wicket.model.IModel;
-import wicket.model.Model;
-
-/**
- * Test for RadioGroup and Radio components
- *
- * @author igor
- * @author jcompagner
- */
-public class CheckGroupTest extends WicketTestCase
-{
- /**
- * @param name
- */
- public CheckGroupTest(String name)
- {
- super(name);
- }
-
- /**
- * mock model object with an embedded property used to test compound
- * property model
- *
- */
- public static class MockModelObject implements Serializable
- {
- private static final long serialVersionUID = 1L;
-
- private Set<String> prop1 = new HashSet<String>();
- private String prop2;
-
- /**
- * @return prop1
- */
- public Set<String> getProp1()
- {
- return prop1;
- }
-
- /**
- * @param prop1
- */
- public void setProp1(Set<String> prop1)
- {
- this.prop1 = prop1;
- }
-
- /**
- * @return prop2
- */
- public String getProp2()
- {
- return prop2;
- }
-
- /**
- * @param prop2
- */
- public void setProp2(String prop2)
- {
- this.prop2 = prop2;
- }
- }
-
- /**
- * test component form processing
- */
- public void testFormProcessing()
- {
- // THIS NEEDS TO BE REWRITTEN BASED ON 1_2 VERSION
-
- MockModelObject modelObject = new MockModelObject();
- MockCheckGroupTestFormPage page = new
MockCheckGroupTestFormPage();
-
- // create component hierarchy
-
- final Form<MockModelObject> form = new
Form<MockModelObject>(page, "form",
- new
CompoundPropertyModel<MockModelObject>(modelObject));
-
- final CheckGroup group = new CheckGroup(form, "prop1");
- final WebMarkupContainer container = new
WebMarkupContainer(group, "container");
-
- // setup some values we will use for testing as well as a test
model
- final String check1 = "check1-selection";
- final String check2 = "check2-selection";
-
- // test model constructors
- List<String> list = new ArrayList<String>();
- IModel<Collection<String>> model = new
Model<Collection<String>>(list);
- final CheckGroup group2 = new CheckGroup<String>(group,
"group2", model);
- assertTrue(group2.getModelObject() == list);
-
- final CheckGroup group3 = new CheckGroup<String>(form,
"group3", list);
- assertTrue(group3.getModelObject() == list);
-
- // set up necessary objects to emulate a form submission
- tester.createRequestCycle();
-
- new Check<String>(container, "check1", new
Model<String>(check1));
- new Check(group, "prop2");
-
- modelObject.setProp2(check2);
-
- // test mock form submissions
-
- modelObject.getProp1().add(check1);
-
- form.onFormSubmitted();
- assertTrue("running with nothing selected - model must be
empty", modelObject.getProp1()
- .size() == 0);
-
- tester.getServletRequest().setParameter(group.getInputName(),
"container:check1");
- form.onFormSubmitted();
- assertTrue("running with choice1 selected - model must only
contain value of check1",
- modelObject.getProp1().size() == 1 &&
modelObject.getProp1().contains(check1));
-
- tester.getServletRequest().setParameter(group.getInputName(),
"prop2");
- form.onFormSubmitted();
- assertTrue("running with choice2 selected - model must only
contain value of check2",
- modelObject.getProp1().size() == 1 &&
modelObject.getProp1().contains(check2));
-
- // throw in some nulls into the request param to make sure they
are
- // ignored
-
tester.getServletRequest().getParameterMap().put(group.getInputName(),
- new String[] { null, "container:check1", null,
"prop2" });
- form.onFormSubmitted();
- assertTrue(
- "running with choice1 and choice2 selected -
model must only contain values of check1 and check2",
- modelObject.getProp1().size() == 2 &&
modelObject.getProp1().contains(check2)
- &&
modelObject.getProp1().contains(check1));
-
-
tester.getServletRequest().getParameterMap().put(group.getInputName(),
- new String[] { "some weird path to test error"
});
- try
- {
- form.onFormSubmitted();
- fail("running with an invalid choice value in the
request param, should fail");
- }
- catch (WicketRuntimeException e)
- {
- ;
- }
- }
-
- /**
- * test component rendering
- *
- * @throws Exception
- */
- public void testRendering() throws Exception
- {
- executeTest(CheckGroupTestPage1.class,
"CheckGroupTestPage1_expected.html");
- executeTest(CheckGroupTestPage2.class,
"CheckGroupTestPage2_expected.html");
- executeTest(CheckGroupTestPage3.class,
"CheckGroupTestPage3_expected.html");
- executeTest(CheckGroupTestPage4.class,
"CheckGroupTestPage4_expected.html");
- try
- {
- executeTest(CheckGroupTestPage5.class, "");
- fail("this will always fail");
- }
- catch (WicketRuntimeException e)
- {
- if (e.getMessage().indexOf(
- "Check component [4:form:check2] cannot
find its parent CheckGroup") < 0)
- {
- fail("failed with wrong exception");
- }
- }
- }
-
- /**
- * @throws Exception
- */
- public void testDisabledCheckGroup() throws Exception
- {
- executeTest(CheckGroupDisabledTestPage.class,
"CheckGroupDisabledTestPage_expected.html");
- }
-
-
-}
+package wicket.markup.html.form;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import wicket.WicketRuntimeException;
+import wicket.WicketTestCase;
+import wicket.markup.html.WebMarkupContainer;
+import wicket.model.CompoundPropertyModel;
+import wicket.model.IModel;
+import wicket.model.Model;
+
+/**
+ * Test for RadioGroup and Radio components
+ *
+ * @author igor
+ * @author jcompagner
+ */
+public class CheckGroupTest extends WicketTestCase
+{
+ /**
+ * @param name
+ */
+ public CheckGroupTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * mock model object with an embedded property used to test compound
+ * property model
+ *
+ */
+ public static class MockModelObject implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Set<String> prop1 = new HashSet<String>();
+ private String prop2;
+
+ /**
+ * @return prop1
+ */
+ public Set<String> getProp1()
+ {
+ return prop1;
+ }
+
+ /**
+ * @param prop1
+ */
+ public void setProp1(Set<String> prop1)
+ {
+ this.prop1 = prop1;
+ }
+
+ /**
+ * @return prop2
+ */
+ public String getProp2()
+ {
+ return prop2;
+ }
+
+ /**
+ * @param prop2
+ */
+ public void setProp2(String prop2)
+ {
+ this.prop2 = prop2;
+ }
+ }
+
+ /**
+ * test component form processing
+ */
+ public void testFormProcessing()
+ {
+ // THIS NEEDS TO BE REWRITTEN BASED ON 1_2 VERSION
+
+ MockModelObject modelObject = new MockModelObject();
+ MockCheckGroupTestFormPage page = new
MockCheckGroupTestFormPage();
+
+ // create component hierarchy
+
+ final Form<MockModelObject> form = new
Form<MockModelObject>(page, "form",
+ new
CompoundPropertyModel<MockModelObject>(modelObject));
+
+ final CheckGroup group = new CheckGroup(form, "prop1");
+ final WebMarkupContainer container = new
WebMarkupContainer(group, "container");
+
+ // setup some values we will use for testing as well as a test
model
+ final String check1 = "check1-selection";
+ final String check2 = "check2-selection";
+
+ // test model constructors
+ List<String> list = new ArrayList<String>();
+ IModel<Collection<String>> model = new
Model<Collection<String>>(list);
+ final CheckGroup group2 = new CheckGroup<String>(group,
"group2", model);
+ assertTrue(group2.getModelObject() == list);
+
+ final CheckGroup group3 = new CheckGroup<String>(form,
"group3", list);
+ assertTrue(group3.getModelObject() == list);
+
+ // set up necessary objects to emulate a form submission
+ tester.createRequestCycle();
+
+ Check choice1 = new Check<String>(container, "check1", new
Model<String>(check1));
+ Check choice2 = new Check(group, "prop2");
+
+ modelObject.setProp2(check2);
+
+ // test mock form submissions
+
+ modelObject.getProp1().add(check1);
+
+ form.onFormSubmitted();
+ assertTrue("running with nothing selected - model must be
empty", modelObject.getProp1()
+ .size() == 0);
+
+ tester.getServletRequest().setParameter(group.getInputName(),
choice1.getValue());
+ form.onFormSubmitted();
+ assertTrue("running with choice1 selected - model must only
contain value of check1",
+ modelObject.getProp1().size() == 1 &&
modelObject.getProp1().contains(check1));
+
+ tester.getServletRequest().setParameter(group.getInputName(),
choice2.getValue());
+ form.onFormSubmitted();
+ assertTrue("running with choice2 selected - model must only
contain value of check2",
+ modelObject.getProp1().size() == 1 &&
modelObject.getProp1().contains(check2));
+
+ // throw in some nulls into the request param to make sure they
are
+ // ignored
+
tester.getServletRequest().getParameterMap().put(group.getInputName(),
+ new String[] { null, choice1.getValue(), null,
choice2.getValue() });
+ form.onFormSubmitted();
+ assertTrue(
+ "running with choice1 and choice2 selected -
model must only contain values of check1 and check2",
+ modelObject.getProp1().size() == 2 &&
modelObject.getProp1().contains(check2)
+ &&
modelObject.getProp1().contains(check1));
+
+
tester.getServletRequest().getParameterMap().put(group.getInputName(),
+ new String[] { "some weird path to test error"
});
+ try
+ {
+ form.onFormSubmitted();
+ fail("running with an invalid choice value in the
request param, should fail");
+ }
+ catch (WicketRuntimeException e)
+ {
+ ;
+ }
+ }
+
+ /**
+ * test component rendering
+ *
+ * @throws Exception
+ */
+ public void testRendering() throws Exception
+ {
+ executeTest(CheckGroupTestPage1.class,
"CheckGroupTestPage1_expected.html");
+ executeTest(CheckGroupTestPage2.class,
"CheckGroupTestPage2_expected.html");
+ executeTest(CheckGroupTestPage3.class,
"CheckGroupTestPage3_expected.html");
+ executeTest(CheckGroupTestPage4.class,
"CheckGroupTestPage4_expected.html");
+ try
+ {
+ executeTest(CheckGroupTestPage5.class, "");
+ fail("this will always fail");
+ }
+ catch (WicketRuntimeException e)
+ {
+ if (e.getMessage().indexOf(
+ "Check component [4:form:check2] cannot
find its parent CheckGroup") < 0)
+ {
+ fail("failed with wrong exception");
+ }
+ }
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testDisabledCheckGroup() throws Exception
+ {
+ executeTest(CheckGroupDisabledTestPage.class,
"CheckGroupDisabledTestPage_expected.html");
+ }
+
+
+}
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage1_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage1_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage1_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage1_expected.html
Tue Nov 14 00:16:36 2006
@@ -6,9 +6,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <Input value="check1" type="checkbox" name="group"
wicket:id="check1">check1</input>
+ <Input value="check0" type="checkbox" name="group"
wicket:id="check1">check1</input>
<span wicket:id="container">
- <input value="container:check2" type="checkbox"
name="group" wicket:id="check2">check2</input>
+ <input value="check1" type="checkbox"
name="group" wicket:id="check2">check2</input>
</span>
</FORM>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage2_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage2_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage2_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage2_expected.html
Tue Nov 14 00:16:36 2006
@@ -5,9 +5,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <input checked="checked" value="check1" type="checkbox"
name="group" wicket:id="check1">check1</input>
+ <input checked="checked" value="check0" type="checkbox"
name="group" wicket:id="check1">check1</input>
<span wicket:id="container">
- <input value="container:check2" type="checkbox"
name="group" wicket:id="check2">check2</input>
+ <input value="check1" type="checkbox"
name="group" wicket:id="check2">check2</input>
</span>
</form>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage3_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage3_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage3_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage3_expected.html
Tue Nov 14 00:16:36 2006
@@ -5,9 +5,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <input value="check1" type="checkbox" name="group"
wicket:id="check1">check1</input>
+ <input value="check0" type="checkbox" name="group"
wicket:id="check1">check1</input>
<span wicket:id="container">
- <input checked="checked"
value="container:check2" type="checkbox" name="group"
wicket:id="check2">check2</input>
+ <input checked="checked" value="check1"
type="checkbox" name="group" wicket:id="check2">check2</input>
</span>
</form>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage4_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage4_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage4_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/CheckGroupTestPage4_expected.html
Tue Nov 14 00:16:36 2006
@@ -5,9 +5,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <input checked="checked" value="check1" type="checkbox"
name="group" wicket:id="check1">check1</input>
+ <input checked="checked" value="check0" type="checkbox"
name="group" wicket:id="check1">check1</input>
<span wicket:id="container">
- <input checked="checked"
value="container:check2" type="checkbox" name="group"
wicket:id="check2">check2</input>
+ <input checked="checked" value="check1"
type="checkbox" name="group" wicket:id="check2">check2</input>
</span>
</form>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
Tue Nov 14 00:16:36 2006
@@ -5,9 +5,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
<span name="group" disabled="disabled" wicket:id="group">
- <input value="radio1" type="radio" name="group"
disabled="disabled" wicket:id="radio1">radio1</input>
+ <input value="radio0" type="radio" name="group"
disabled="disabled" wicket:id="radio1">radio1</input>
<span wicket:id="container">
- <input checked="checked"
value="container:radio2" type="radio" name="group" disabled="disabled"
wicket:id="radio2">radio2</input>
+ <input checked="checked" value="radio1"
type="radio" name="group" disabled="disabled" wicket:id="radio2">radio2</input>
</span>
</span>
</form>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage1_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage1_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage1_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage1_expected.html
Tue Nov 14 00:16:36 2006
@@ -5,9 +5,9 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <input value="radio1" type="radio" name="group"
wicket:id="radio1">radio1</input>
+ <input value="radio0" type="radio" name="group"
wicket:id="radio1">radio1</input>
<span wicket:id="container">
- <input checked="checked"
value="container:radio2" type="radio" name="group"
wicket:id="radio2">radio2</input>
+ <input checked="checked" value="radio1"
type="radio" name="group" wicket:id="radio2">radio2</input>
</span>
</form>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage3_expected.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage3_expected.html?view=diff&rev=474693&r1=474692&r2=474693
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage3_expected.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/form/RadioGroupTestPage3_expected.html
Tue Nov 14 00:16:36 2006
@@ -4,8 +4,8 @@
<div style="display:none"><input type="hidden" name="form:hf:fs"
id="form:hf:fs"/>
<input type="hidden" name="wicketState" id="form:hf:ws"/></div>
- <input checked="checked" value="check1" type="radio"
name="radio" wicket:id="check1">Yes
- <input checked="checked" value="check2" type="radio"
name="radio" wicket:id="check2">No
+ <input checked="checked" value="radio0" type="radio"
name="radio" wicket:id="check1">Yes
+ <input checked="checked" value="radio1" type="radio"
name="radio" wicket:id="check2">No
</form>
</body>