You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/03/01 19:34:29 UTC
svn commit: r749071 - in /incubator/click/trunk/click: documentation/docs/
framework/src/org/apache/click/control/
framework/test/org/apache/click/control/
Author: sabob
Date: Sun Mar 1 18:34:28 2009
New Revision: 749071
URL: http://svn.apache.org/viewvc?rev=749071&view=rev
Log:
fixed fieldset parent bug. CLK-497
Modified:
incubator/click/trunk/click/documentation/docs/roadmap-changes.html
incubator/click/trunk/click/framework/src/org/apache/click/control/FieldSet.java
incubator/click/trunk/click/framework/test/org/apache/click/control/FieldSetTest.java
incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java
Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=749071&r1=749070&r2=749071&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sun Mar 1 18:34:28 2009
@@ -101,6 +101,10 @@
</div>
<ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
<li class="change">
+ Fixed a bug where FieldSet was not set as the parent of its child controls
+ [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-497">497</a>].
+ </li>
+ <li class="change">
Fixed Column sorting to recognize numbers inside strings
[<a target='_blank' href="https://issues.apache.org/click/browse/CLK-489">489</a>].
</li>
Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/FieldSet.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/FieldSet.java?rev=749071&r1=749070&r2=749071&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/FieldSet.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/FieldSet.java Sun Mar 1 18:34:28 2009
@@ -1107,6 +1107,7 @@
*/
public Control insert(Control control, int index) {
super.insert(control, index);
+ control.setParent(FieldSet.this);
if (control instanceof Field) {
Field field = (Field) control;
@@ -1145,6 +1146,9 @@
public boolean remove(Control control) {
boolean removed = super.remove(control);
+ if (control.getParent() == FieldSet.this) {
+ control.setParent(null);
+ }
if (removed && control instanceof Field) {
Field field = (Field) control;
Modified: incubator/click/trunk/click/framework/test/org/apache/click/control/FieldSetTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/control/FieldSetTest.java?rev=749071&r1=749070&r2=749071&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/control/FieldSetTest.java (original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/control/FieldSetTest.java Sun Mar 1 18:34:28 2009
@@ -19,6 +19,7 @@
package org.apache.click.control;
import junit.framework.TestCase;
+import org.apache.click.Control;
import org.apache.click.MockContext;
/**
@@ -377,6 +378,66 @@
}
/**
+ * Test that Fields added to FieldSet, correctly returns FieldSet as their
+ * parent.
+ *
+ * CLK-497
+ */
+ public void testFieldParent() {
+ // Initially fieldSet contains 1 hidden field
+ assertTrue(fieldSet.getControls().size() == 1);
+
+ TextField nameField = new TextField("score");
+ fieldSet.add(nameField);
+
+ assertTrue(fieldSet.getControls().size() == 2);
+
+ // Test that Field parent is a FieldSet
+ assertEquals(FieldSet.class, nameField.getParent().getClass());
+
+ assertTrue(fieldSet.remove((Control) nameField));
+
+ assertTrue(nameField.getParent() == null);
+ assertTrue(fieldSet.getControls().size() == 1);
+ }
+
+ /**
+ * Test the isDisabled() for a child component. Intent is to ensure that a child
+ * component of the FieldSet is disabled when the FieldSet is itself disabled.
+ */
+ public void testIsDisabled() {
+ // Fieldset is not disabled.
+ assertFalse(this.fieldSet.isDisabled());
+
+ // Textfield inside is not disabled.
+ assertFalse(this.trackField.isDisabled());
+
+ // Change fieldset state.
+ this.fieldSet.setDisabled(true);
+
+ // Textfield is now disabled too.
+ assertTrue(this.trackField.isDisabled());
+ }
+
+ /**
+ * Test the isReadonly() for a child component. Intent is to ensure that a child
+ * component of the FieldSet is disabled when the FieldSet is itself disabled.
+ */
+ public void testIsReadonly() {
+ // Fieldset is not disabled.
+ assertFalse(this.fieldSet.isReadonly());
+
+ // Textfield inside is not disabled.
+ assertFalse(this.trackField.isReadonly());
+
+ // Change fieldset state.
+ this.fieldSet.setReadonly(true);
+
+ // Textfield is now disabled too.
+ assertTrue(this.trackField.isReadonly());
+ }
+
+ /**
* A custom Div container.
*/
static class Div extends AbstractContainer {
Modified: incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java?rev=749071&r1=749070&r2=749071&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java (original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java Sun Mar 1 18:34:28 2009
@@ -535,7 +535,7 @@
* $form.fields.name <- name this is a TextField
* $form.fields.div <- div is a AbstractContainer
* $form.fields.button <- button is a Submit
- *
+ *
* Also check that Form.getFields() returns a cached Map so that access to
* Form.getFields() is fast.
*
@@ -708,6 +708,42 @@
}
/**
+ * Test the isDisabled() for a child component. Intent is to ensure that a
+ * child component of the Form is disabled when the Form is itself disabled.
+ */
+ public void testIsDisabled() {
+ // Form is not disabled.
+ assertFalse(this.form.isDisabled());
+
+ // Hiddenfield inside is not disabled.
+ assertFalse(this.trackField.isDisabled());
+
+ // Change form state.
+ this.form.setDisabled(true);
+
+ // Hiddenfield is now disabled too.
+ assertTrue(this.trackField.isDisabled());
+ }
+
+ /**
+ * Test the isReadonly() for a child component. Intent is to ensure that a
+ * child component of the Form is disabled when the Form is itself disabled.
+ */
+ public void testIsReadonly() {
+ // Form is not disabled.
+ assertFalse(this.form.isReadonly());
+
+ // Hiddenfield inside is not disabled.
+ assertFalse(this.trackField.isReadonly());
+
+ // Change form state.
+ this.form.setReadonly(true);
+
+ // Hiddenfield is now disabled too.
+ assertTrue(this.trackField.isReadonly());
+ }
+
+ /**
* Populate the given Form with hidden fields.
*
* @param count the number of hidden fields to add