You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2003/03/17 19:10:50 UTC
cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry IForm.java
hlship 2003/03/17 10:10:50
Modified: framework/src/org/apache/tapestry/form TextArea.jwc
Submit.jwc DatePicker.java RadioGroup.jwc
ImageSubmit.jwc PropertySelection.java Upload.java
ListEdit.java Button.jwc Hidden.java DatePicker.jwc
TextArea.java Submit.java Checkbox.java
TextField.jwc AbstractFormComponent.java
Checkbox.jwc Select.java Select.jwc ListEdit.jwc
ImageSubmit.java Hidden.jwc Form.java Upload.jwc
RadioGroup.java Button.java PropertySelection.jwc
IFormComponent.java AbstractTextField.java
junit/src/org/apache/tapestry/junit/valid TestingForm.java
TestingField.java
framework/src/org/apache/tapestry/valid ValidField.java
ValidField.jwc
contrib/src/org/apache/tapestry/contrib/form
MultiplePropertySelection.java
MultiplePropertySelection.jwc
framework/src/org/apache/tapestry IForm.java
Log:
Slight refactor of relationship between components and forms.
Make use of two declared properties ('name' and'form') for all form components.
Revision Changes Path
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/TextArea.jwc
Index: TextArea.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/TextArea.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TextArea.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ TextArea.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -18,4 +18,7 @@
<reserved-parameter name="name"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/Submit.jwc
Index: Submit.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Submit.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Submit.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Submit.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -20,5 +20,8 @@
<reserved-parameter name="name"/>
<reserved-parameter name="type"/>
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
</component-specification>
1.3 +7 -15 jakarta-tapestry/framework/src/org/apache/tapestry/form/DatePicker.java
Index: DatePicker.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/DatePicker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DatePicker.java 15 Mar 2003 21:22:11 -0000 1.2
+++ DatePicker.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -81,8 +81,6 @@
public abstract class DatePicker extends AbstractFormComponent
{
- private String _name;
-
public abstract String getFormat();
public abstract Date getValue();
@@ -94,10 +92,8 @@
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
String format = getFormat();
@@ -120,7 +116,7 @@
writer.beginEmpty("input");
writer.attribute("type", "text");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
writer.attribute("maxlength", format.length());
writer.attribute("size", format.length());
@@ -132,7 +128,7 @@
writer.beginEmpty("input");
writer.attribute("type", "hidden");
- writer.attribute("name", _name + "$millis");
+ writer.attribute("name", name + "$millis");
if (value == null)
writer.attribute("value", "");
@@ -141,12 +137,12 @@
writer.beginEmpty("input");
writer.attribute("type", "hidden");
- writer.attribute("name", _name + "$format");
+ writer.attribute("name", name + "$format");
writer.attribute("value", format);
writer.beginEmpty("input");
writer.attribute("type", "button");
- writer.attribute("name", _name + "$button");
+ writer.attribute("name", name + "$button");
if (disabled)
writer.attribute("disabled", "disabled");
@@ -160,7 +156,7 @@
if (disabled)
return;
- String textValue = cycle.getRequestContext().getParameter(_name);
+ String textValue = cycle.getRequestContext().getParameter(name);
if (Tapestry.isNull(textValue))
return;
@@ -178,9 +174,5 @@
}
- public String getName()
- {
- return _name;
- }
}
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/RadioGroup.jwc
Index: RadioGroup.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/RadioGroup.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RadioGroup.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ RadioGroup.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -14,4 +14,7 @@
<parameter name="disabled" type="boolean" direction="in"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.2 +5 -2 jakarta-tapestry/framework/src/org/apache/tapestry/form/ImageSubmit.jwc
Index: ImageSubmit.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/ImageSubmit.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ImageSubmit.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ ImageSubmit.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -64,5 +64,8 @@
<reserved-parameter name="type"/>
<reserved-parameter name="src"/>
<reserved-parameter name="border"/>
-
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.5 +4 -19 jakarta-tapestry/framework/src/org/apache/tapestry/form/PropertySelection.java
Index: PropertySelection.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/PropertySelection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropertySelection.java 17 Mar 2003 03:25:19 -0000 1.4
+++ PropertySelection.java 17 Mar 2003 18:10:48 -0000 1.5
@@ -89,8 +89,6 @@
public abstract class PropertySelection extends AbstractFormComponent
{
- private String _name;
-
/**
* A shared instance of {@link SelectPropertySelectionRenderer}.
*
@@ -110,17 +108,6 @@
new RadioPropertySelectionRenderer();
/**
- * Returns the name assigned to this PropertySelection by the {@link Form}
- * that wraps it.
- *
- **/
-
- public String getName()
- {
- return _name;
- }
-
- /**
* Renders the component, much of which is the responsiblity
* of the {@link IPropertySelectionRenderer renderer}. The possible options,
* thier labels, and the values to be encoded in the form are provided
@@ -132,11 +119,9 @@
{
IForm form = getForm(cycle);
- updateDelegate(form);
-
boolean rewinding = form.isRewinding();
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
if (rewinding)
{
@@ -145,7 +130,7 @@
if (isDisabled())
return;
- String optionValue = cycle.getRequestContext().getParameter(_name);
+ String optionValue = cycle.getRequestContext().getParameter(name);
Object value = (optionValue == null) ? null : getModel().translateValue(optionValue);
@@ -163,7 +148,7 @@
}
writer.begin("select");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isDisabled())
writer.attribute("disabled");
1.3 +4 -13 jakarta-tapestry/framework/src/org/apache/tapestry/form/Upload.java
Index: Upload.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Upload.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Upload.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Upload.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -74,25 +74,16 @@
public abstract class Upload extends AbstractFormComponent
{
- private String _name;
-
- public String getName()
- {
- return _name;
- }
-
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
if (form.isRewinding())
{
if (!isDisabled())
- setFile(cycle.getRequestContext().getUploadFile(_name));
+ setFile(cycle.getRequestContext().getUploadFile(name));
return;
}
@@ -104,7 +95,7 @@
writer.beginEmpty("input");
writer.attribute("type", "file");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isDisabled())
writer.attribute("disabled");
1.3 +3 -8 jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.java
Index: ListEdit.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListEdit.java 15 Mar 2003 21:22:11 -0000 1.2
+++ ListEdit.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -58,7 +58,6 @@
import java.io.IOException;
import java.util.Iterator;
-import org.apache.tapestry.AbstractComponent;
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IActionListener;
import org.apache.tapestry.IBinding;
@@ -82,18 +81,14 @@
*
**/
-public abstract class ListEdit extends AbstractComponent
+public abstract class ListEdit extends AbstractFormComponent
{
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
Iterator i = null;
- IForm form = Form.get(cycle);
- if (form == null)
- throw new ApplicationRuntimeException(
- Tapestry.getString("must-be-wrapped-by-form", "ListEdit"),
- this);
+ IForm form = getForm(cycle);
boolean cycleRewinding = cycle.isRewinding();
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/Button.jwc
Index: Button.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Button.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Button.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Button.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -16,5 +16,8 @@
<reserved-parameter name="name"/>
<reserved-parameter name="type"/>
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
</component-specification>
1.3 +4 -10 jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.java
Index: Hidden.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Hidden.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Hidden.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -77,19 +77,13 @@
public abstract class Hidden extends AbstractFormComponent
{
- private String _name;
-
- public String getName()
- {
- return _name;
- }
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
boolean formRewound = form.isRewinding();
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
// If the form containing the Hidden isn't rewound, then render.
@@ -121,13 +115,13 @@
writer.beginEmpty("input");
writer.attribute("type", "hidden");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
writer.attribute("value", externalValue);
return;
}
- String externalValue = cycle.getRequestContext().getParameter(_name);
+ String externalValue = cycle.getRequestContext().getParameter(name);
Object value = null;
if (getEncode())
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/DatePicker.jwc
Index: DatePicker.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/DatePicker.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatePicker.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ DatePicker.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -13,6 +13,9 @@
<parameter name="format" direction="in" type="java.lang.String" required="no"/>
<parameter name="disabled" direction="in" type="boolean" required="no"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
<private-asset name="script" resource-path="DatePicker.js"/>
</component-specification>
1.3 +4 -12 jakarta-tapestry/framework/src/org/apache/tapestry/form/TextArea.java
Index: TextArea.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/TextArea.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TextArea.java 15 Mar 2003 21:22:11 -0000 1.2
+++ TextArea.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -72,12 +72,6 @@
public abstract class TextArea extends AbstractFormComponent
{
- private String _name;
-
- public String getName()
- {
- return _name;
- }
/**
* Renders the form element, or responds when the form containing the element
@@ -88,8 +82,6 @@
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
// It isn't enough to know whether the cycle in general is rewinding, need to know
// specifically if the form which contains this component is rewinding.
@@ -98,12 +90,12 @@
// Used whether rewinding or not.
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
if (rewinding)
{
if (!isDisabled())
- setValue(cycle.getRequestContext().getParameter(_name));
+ setValue(cycle.getRequestContext().getParameter(name));
return;
}
@@ -113,7 +105,7 @@
writer.begin("textarea");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isDisabled())
writer.attribute("disabled");
1.3 +5 -15 jakarta-tapestry/framework/src/org/apache/tapestry/form/Submit.java
Index: Submit.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Submit.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Submit.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Submit.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -78,26 +78,16 @@
*
**/
-public abstract class Submit extends AbstractFormComponent
-{
-
- private String _name;
-
- public String getName()
- {
- return _name;
- }
+public abstract class Submit extends AbstractFormComponent{
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
boolean rewinding = form.isRewinding();
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
if (rewinding)
{
@@ -111,7 +101,7 @@
// with its name and value (the value serves double duty as both
// the label on the button, and the parameter value).
- String value = cycle.getRequestContext().getParameter(_name);
+ String value = cycle.getRequestContext().getParameter(name);
// If the value isn't there, then this button wasn't
// selected.
@@ -134,7 +124,7 @@
writer.beginEmpty("input");
writer.attribute("type", "submit");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isDisabled())
writer.attribute("disabled");
1.3 +4 -13 jakarta-tapestry/framework/src/org/apache/tapestry/form/Checkbox.java
Index: Checkbox.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Checkbox.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Checkbox.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Checkbox.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -72,13 +72,6 @@
public abstract class Checkbox extends AbstractFormComponent
{
- private String _name;
-
- public String getName()
- {
- return _name;
- }
-
/**
* Renders the form elements, or responds when the form containing the element
* is submitted (by checking {@link Form#isRewinding()}.
@@ -92,16 +85,14 @@
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
// Used whether rewinding or not.
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
if (form.isRewinding())
{
- String value = cycle.getRequestContext().getParameter(_name);
+ String value = cycle.getRequestContext().getParameter(name);
setSelected((value != null));
@@ -111,7 +102,7 @@
writer.beginEmpty("input");
writer.attribute("type", "checkbox");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isDisabled())
writer.attribute("disabled");
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/TextField.jwc
Index: TextField.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/TextField.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TextField.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ TextField.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -23,4 +23,7 @@
<reserved-parameter name="type"/>
<reserved-parameter name="value"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.3 +16 -26 jakarta-tapestry/framework/src/org/apache/tapestry/form/AbstractFormComponent.java
Index: AbstractFormComponent.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/AbstractFormComponent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractFormComponent.java 15 Mar 2003 21:22:11 -0000 1.2
+++ AbstractFormComponent.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -76,7 +76,10 @@
public abstract class AbstractFormComponent extends AbstractComponent implements IFormComponent
{
/**
- * Returns the {@link Form} wrapping this component.
+ * Returns the {@link Form} wrapping this component. Invokes
+ * {@link #setForm(IForm)} (so that the component may know, later, what the
+ * form is). Also, if the form has a delegate,
+ * then {@link IValidationDelegate#setFormComponent(IFormComponent)} is invoked.
*
* @throws RequestCycleException if the component is not wrapped by a {@link Form}.
*
@@ -91,15 +94,21 @@
Tapestry.getString("AbstractFormComponent.must-be-contained-by-form"),
this);
+ setForm(result);
+
+ IValidationDelegate delegate = result.getDelegate();
+
+ if (delegate != null)
+ delegate.setFormComponent(this);
+
return result;
}
- public IForm getForm()
- {
- return Form.get(getPage().getRequestCycle());
- }
+ public abstract IForm getForm();
+ public abstract void setForm(IForm form);
- abstract public String getName();
+ public abstract String getName();
+ public abstract void setName(String name);
/**
* Implemented in some subclasses to provide a display name (suitable
@@ -111,24 +120,5 @@
public String getDisplayName()
{
return null;
- }
-
- /**
- * Invoked by components (other than {@link org.apache.tapestry.valid.ValidField})
- * to inform the {@link org.apache.tapestry.valid.IValidationDelegate} for the
- * {@link Form}, if any, that it is the current component. This allows
- * non-ValidField components to still participate in the validation system,
- * to a lesser degree.
- *
- * @since 2.4
- *
- **/
-
- protected void updateDelegate(IForm form)
- {
- IValidationDelegate delegate = form.getDelegate();
-
- if (delegate != null)
- delegate.setFormComponent(this);
}
}
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/Checkbox.jwc
Index: Checkbox.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Checkbox.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Checkbox.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Checkbox.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -30,4 +30,7 @@
<reserved-parameter name="checked"/>
<reserved-parameter name="name"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.3 +4 -13 jakarta-tapestry/framework/src/org/apache/tapestry/form/Select.java
Index: Select.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Select.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Select.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Select.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -88,13 +88,6 @@
private Set _selections;
private int _nextOptionId;
- private String _name;
-
- public String getName()
- {
- return _name;
- }
-
/**
* Used by the <code>Select</code> to record itself as a
* {@link IRequestCycle} attribute, so that the
@@ -147,8 +140,6 @@
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
-
- updateDelegate(form);
if (cycle.getAttribute(ATTRIBUTE_NAME) != null)
throw new ApplicationRuntimeException(Tapestry.getString("Select.may-not-nest"), this);
@@ -160,19 +151,19 @@
// Used whether rewinding or not.
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
cycle.setAttribute(ATTRIBUTE_NAME, this);
if (_rewinding)
{
- _selections = buildSelections(cycle, _name);
+ _selections = buildSelections(cycle, name);
}
else
{
writer.begin("select");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (isMultiple())
writer.attribute("multiple");
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/Select.jwc
Index: Select.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Select.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Select.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Select.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -15,4 +15,7 @@
<reserved-parameter name="name"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.jwc
Index: ListEdit.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListEdit.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ ListEdit.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -21,6 +21,9 @@
<parameter name="index" type="int"/>
<parameter name="element" type="java.lang.String" direction="in"/>
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
</component-specification>
1.3 +6 -17 jakarta-tapestry/framework/src/org/apache/tapestry/form/ImageSubmit.java
Index: ImageSubmit.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/ImageSubmit.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ImageSubmit.java 15 Mar 2003 21:22:11 -0000 1.2
+++ ImageSubmit.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -83,8 +83,6 @@
public abstract class ImageSubmit extends AbstractFormComponent
{
- private String _name;
-
public abstract IBinding getPointBinding();
public abstract IBinding getSelectedBinding();
@@ -93,16 +91,12 @@
{
IForm form = getForm(cycle);
- updateDelegate(form);
-
boolean rewinding = form.isRewinding();
String nameOverride = getNameOverride();
- if (nameOverride == null)
- _name = form.getElementId(this);
- else
- _name = form.getElementId(this, nameOverride);
+ String name =
+ nameOverride == null ? form.getElementId(this) : form.getElementId(this, nameOverride);
if (rewinding)
{
@@ -116,7 +110,7 @@
// Image clicks get submitted as two request parameters:
// foo.x and foo.y
- String parameterName = _name + ".x";
+ String parameterName = name + ".x";
String value = context.getParameter(parameterName);
@@ -135,7 +129,7 @@
{
int x = Integer.parseInt(value);
- parameterName = _name + ".y";
+ parameterName = name + ".y";
value = context.getParameter(parameterName);
int y = Integer.parseInt(value);
@@ -170,7 +164,7 @@
writer.beginEmpty("input");
writer.attribute("type", "image");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
if (disabled)
writer.attribute("disabled");
@@ -194,11 +188,6 @@
public abstract IAsset getImage();
public abstract IActionListener getListener();
-
- public String getName()
- {
- return _name;
- }
public abstract Object getTag();
1.2 +6 -3 jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.jwc
Index: Hidden.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Hidden.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Hidden.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -30,5 +30,8 @@
</parameter>
<parameter name="encode" type="boolean" direction="in"/>
-
-</component-specification>
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
+</component-specification>
\ No newline at end of file
1.3 +5 -4 jakarta-tapestry/framework/src/org/apache/tapestry/form/Form.java
Index: Form.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Form.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Form.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Form.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -65,7 +65,6 @@
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IActionListener;
import org.apache.tapestry.IBinding;
-import org.apache.tapestry.IComponent;
import org.apache.tapestry.IDirect;
import org.apache.tapestry.IEngine;
import org.apache.tapestry.IForm;
@@ -213,7 +212,7 @@
* @since 1.0.2
**/
- public String getElementId(IComponent component)
+ public String getElementId(IFormComponent component)
{
return getElementId(component, component.getId());
}
@@ -231,7 +230,7 @@
*
**/
- public String getElementId(IComponent component, String baseId)
+ public String getElementId(IFormComponent component, String baseId)
{
String result = _elementIdAllocator.allocateId(baseId);
@@ -268,6 +267,8 @@
}
_allocatedIdIndex++;
+
+ component.setName(result);
return result;
}
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/Upload.jwc
Index: Upload.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Upload.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Upload.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ Upload.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -25,4 +25,7 @@
<reserved-parameter name="type"/>
<reserved-parameter name="name"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.3 +3 -14 jakarta-tapestry/framework/src/org/apache/tapestry/form/RadioGroup.java
Index: RadioGroup.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/RadioGroup.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RadioGroup.java 15 Mar 2003 21:22:11 -0000 1.2
+++ RadioGroup.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -84,11 +84,6 @@
// Radio was selected by the user.
private int _selectedOption;
- // The HTML field name used for this group (i.e., by all Radio buttons
- // within this group).
-
- private String _name;
-
private boolean _rewinding;
private boolean _rendering;
private int _nextOptionId;
@@ -109,12 +104,6 @@
public abstract IBinding getSelectedBinding();
-
- public String getName()
- {
- return _name;
- }
-
public int getNextOptionId()
{
if (!_rendering)
@@ -204,7 +193,7 @@
// Used whether rewinding or not.
- _name = form.getElementId(this);
+ String name = form.getElementId(this);
cycle.setAttribute(ATTRIBUTE_NAME, this);
@@ -213,7 +202,7 @@
if (_rewinding)
{
- String value = cycle.getRequestContext().getParameter(_name);
+ String value = cycle.getRequestContext().getParameter(name);
if (value == null)
_selectedOption = -1;
else
1.3 +40 -74 jakarta-tapestry/framework/src/org/apache/tapestry/form/Button.java
Index: Button.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Button.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Button.java 15 Mar 2003 21:22:11 -0000 1.2
+++ Button.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -55,7 +55,6 @@
package org.apache.tapestry.form;
-import org.apache.tapestry.IBinding;
import org.apache.tapestry.IForm;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
@@ -72,77 +71,44 @@
* @author Malcolm Edgar
* @version $Id$
**/
-public class Button extends AbstractFormComponent
+
+public abstract class Button extends AbstractFormComponent
{
- private String _label;
- private boolean _disabled;
- private IBinding _selectedBinding;
- private String _name;
-
- public String getName()
- {
- return _name;
- }
-
- public void setSelectedBinding(IBinding value)
- {
- _selectedBinding = value;
- }
-
- public IBinding getSelectedBinding()
- {
- return _selectedBinding;
- }
-
- protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
- {
- IForm form = getForm(cycle);
-
- updateDelegate(form);
-
- boolean rewinding = form.isRewinding();
-
- _name = form.getElementId(this);
-
- if (rewinding)
- {
- return;
- }
-
- writer.beginEmpty("input");
- writer.attribute("type", "button");
- writer.attribute("name", _name);
-
- if (_disabled)
- {
- writer.attribute("disabled");
- }
- if (_label != null)
- {
- writer.attribute("value", _label);
- }
- generateAttributes(writer, cycle);
-
- writer.closeTag();
- }
-
- public String getLabel()
- {
- return _label;
- }
-
- public void setLabel(String label)
- {
- _label = label;
- }
-
- public boolean isDisabled()
- {
- return _disabled;
- }
-
- public void setDisabled(boolean disabled)
- {
- _disabled = disabled;
- }
+ protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
+ {
+ IForm form = getForm(cycle);
+
+ boolean rewinding = form.isRewinding();
+
+ String name = form.getElementId(this);
+
+ if (rewinding)
+ {
+ return;
+ }
+
+ writer.beginEmpty("input");
+ writer.attribute("type", "button");
+ writer.attribute("name", name);
+
+ if (isDisabled())
+ {
+ writer.attribute("disabled");
+ }
+
+ String label = getLabel();
+
+ if (label != null)
+ {
+ writer.attribute("value", label);
+ }
+
+ generateAttributes(writer, cycle);
+
+ writer.closeTag();
+ }
+
+ public abstract String getLabel();
+
+ public abstract boolean isDisabled();
}
1.2 +5 -2 jakarta-tapestry/framework/src/org/apache/tapestry/form/PropertySelection.jwc
Index: PropertySelection.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/PropertySelection.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertySelection.jwc 5 Mar 2003 22:59:24 -0000 1.1
+++ PropertySelection.jwc 17 Mar 2003 18:10:48 -0000 1.2
@@ -40,5 +40,8 @@
</parameter>
<reserved-parameter name="name"/>
-
+
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.2 +11 -1 jakarta-tapestry/framework/src/org/apache/tapestry/form/IFormComponent.java
Index: IFormComponent.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/IFormComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IFormComponent.java 5 Mar 2003 22:59:24 -0000 1.1
+++ IFormComponent.java 17 Mar 2003 18:10:48 -0000 1.2
@@ -95,6 +95,16 @@
**/
public String getName();
+
+ /**
+ * Invoked by {@link IForm#getElementId(IComponent)} when a name is created
+ * for a form component.
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void setName(String name);
/**
* May be implemented to return a user-presentable, localized name for the component,
1.3 +5 -14 jakarta-tapestry/framework/src/org/apache/tapestry/form/AbstractTextField.java
Index: AbstractTextField.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/AbstractTextField.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractTextField.java 15 Mar 2003 21:22:11 -0000 1.2
+++ AbstractTextField.java 17 Mar 2003 18:10:48 -0000 1.3
@@ -73,13 +73,6 @@
public abstract class AbstractTextField extends AbstractFormComponent
{
- private String _name;
-
- public String getName()
- {
- return _name;
- }
-
/**
* Renders the form element, or responds when the form containing the element
* is submitted (by checking {@link Form#isRewinding()}.
@@ -91,8 +84,6 @@
String value;
IForm form = getForm(cycle);
-
- updateDelegate(form);
// It isn't enough to know whether the cycle in general is rewinding, need to know
// specifically if the form which contains this component is rewinding.
@@ -107,13 +98,13 @@
// Used whether rewinding or not.
- _name = form.getElementId(this);
-
+ String name = form.getElementId(this);
+
if (rewinding)
{
if (!isDisabled())
{
- value = cycle.getRequestContext().getParameter(_name);
+ value = cycle.getRequestContext().getParameter(name);
updateValue(value);
}
@@ -128,7 +119,7 @@
if (isDisabled())
writer.attribute("disabled");
- writer.attribute("name", _name);
+ writer.attribute("name", name);
int displayWidth = getDisplayWidth();
int maximumLength = getMaximumLength();
1.3 +4 -3 jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingForm.java
Index: TestingForm.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingForm.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestingForm.java 15 Mar 2003 21:22:26 -0000 1.2
+++ TestingForm.java 17 Mar 2003 18:10:50 -0000 1.3
@@ -70,6 +70,7 @@
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.IPageLoader;
import org.apache.tapestry.form.FormEventType;
+import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.spec.BaseLocatable;
import org.apache.tapestry.spec.ComponentSpecification;
import org.apache.tapestry.valid.IValidationDelegate;
@@ -105,12 +106,12 @@
{
}
- public String getElementId(IComponent component)
+ public String getElementId(IFormComponent component)
{
return null;
}
- public String getElementId(IComponent component, String baseId)
+ public String getElementId(IFormComponent component, String baseId)
{
return null;
}
1.3 +11 -1 jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingField.java
Index: TestingField.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingField.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestingField.java 15 Mar 2003 21:22:26 -0000 1.2
+++ TestingField.java 17 Mar 2003 18:10:50 -0000 1.3
@@ -99,6 +99,11 @@
setPage(page);
}
+
+ public void setForm(IForm form)
+ {
+ _form = form;
+ }
public String getDisplayName()
{
@@ -129,4 +134,9 @@
{
return "TestingField[" + _displayName + "]";
}
+
+ public void setName(String name)
+ {
+ }
+
}
1.3 +5 -5 jakarta-tapestry/framework/src/org/apache/tapestry/valid/ValidField.java
Index: ValidField.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/valid/ValidField.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ValidField.java 15 Mar 2003 21:22:22 -0000 1.2
+++ ValidField.java 17 Mar 2003 18:10:50 -0000 1.3
@@ -120,8 +120,8 @@
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
- IValidationDelegate delegate = getForm().getDelegate();
- IValidator validator = getValidator();
+ IForm form = getForm(cycle);
+ IValidationDelegate delegate = form.getDelegate();
if (delegate == null)
throw new ApplicationRuntimeException(
@@ -131,9 +131,9 @@
getForm().getExtendedId()),
this);
- boolean rendering = !cycle.isRewinding();
+ IValidator validator = getValidator();
- delegate.setFormComponent(this);
+ boolean rendering = !cycle.isRewinding();
if (rendering)
delegate.writePrefix(writer, cycle, this, validator);
1.2 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/valid/ValidField.jwc
Index: ValidField.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/valid/ValidField.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ValidField.jwc 5 Mar 2003 22:59:40 -0000 1.1
+++ ValidField.jwc 17 Mar 2003 18:10:50 -0000 1.2
@@ -41,4 +41,7 @@
<reserved-parameter name="value"/>
<reserved-parameter name="name"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.3 +20 -56 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/MultiplePropertySelection.java
Index: MultiplePropertySelection.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/MultiplePropertySelection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MultiplePropertySelection.java 15 Mar 2003 21:22:14 -0000 1.2
+++ MultiplePropertySelection.java 17 Mar 2003 18:10:50 -0000 1.3
@@ -141,13 +141,8 @@
*
**/
-public class MultiplePropertySelection extends AbstractFormComponent
+public abstract class MultiplePropertySelection extends AbstractFormComponent
{
- private IPropertySelectionModel model;
- private boolean disabled;
- private IMultiplePropertySelectionRenderer renderer = DEFAULT_CHECKBOX_RENDERER;
- private IBinding selectedListBinding;
- private String name;
/**
* A shared instance of {@link CheckBoxMultiplePropertySelectionRenderer}.
@@ -157,26 +152,11 @@
public static final IMultiplePropertySelectionRenderer DEFAULT_CHECKBOX_RENDERER =
new CheckBoxMultiplePropertySelectionRenderer();
- public IBinding getSelectedListBinding()
- {
- return selectedListBinding;
- }
-
- public void setSelectedListBinding(IBinding value)
- {
- selectedListBinding = value;
- }
-
- /**
- * Returns the name assigned to this PropertySelection by the
- * {@link IForm}
- * that wraps it.
- *
- **/
+ public abstract IBinding getSelectedListBinding();
- public String getName()
+ public void finishLoad()
{
- return name;
+ setRenderer(DEFAULT_CHECKBOX_RENDERER);
}
/**
@@ -185,15 +165,7 @@
*
**/
- public boolean isDisabled()
- {
- return disabled;
- }
-
- public void setDisabled(boolean disabled)
- {
- this.disabled = disabled;
- }
+ public abstract boolean isDisabled();
/**
* Renders the component, much of which is the responsiblity
@@ -207,23 +179,26 @@
{
IForm form = getForm(cycle);
- updateDelegate(form);
-
boolean rewinding = form.isRewinding();
- name = form.getElementId(this);
+ String name = form.getElementId(this);
- List selectedList = (List) selectedListBinding.getObject("selectedList", List.class);
+ List selectedList = (List) getSelectedListBinding().getObject("selectedList", List.class);
if (selectedList == null)
throw Tapestry.createRequiredParameterException(this, "selectedList");
+ IPropertySelectionModel model = getModel();
+
+ if (model == null)
+ throw Tapestry.createRequiredParameterException(this, "model");
+
// Handle the form processing first.
if (rewinding)
{
// If disabled, ignore anything that comes up from the client.
- if (disabled)
+ if (isDisabled())
return;
// get all the values
@@ -236,6 +211,7 @@
// Nothing was selected
if (optionValues != null)
{
+
// Go through the array and translate and put back in the list
for (int i = 0; i < optionValues.length; i++)
{
@@ -250,6 +226,8 @@
return;
}
+ IMultiplePropertySelectionRenderer renderer = getRenderer();
+
// Start rendering
renderer.beginRender(this, writer, cycle);
@@ -270,24 +248,10 @@
renderer.endRender(this, writer, cycle);
}
- public IPropertySelectionModel getModel()
- {
- return model;
- }
-
- public void setModel(IPropertySelectionModel model)
- {
- this.model = model;
- }
+ public abstract IPropertySelectionModel getModel();
- public IMultiplePropertySelectionRenderer getRenderer()
- {
- return renderer;
- }
+ public abstract IMultiplePropertySelectionRenderer getRenderer();
- public void setRenderer(IMultiplePropertySelectionRenderer renderer)
- {
- this.renderer = renderer;
- }
+ public abstract void setRenderer(IMultiplePropertySelectionRenderer renderer);
}
1.2 +4 -1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/MultiplePropertySelection.jwc
Index: MultiplePropertySelection.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/MultiplePropertySelection.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultiplePropertySelection.jwc 5 Mar 2003 23:02:32 -0000 1.1
+++ MultiplePropertySelection.jwc 17 Mar 2003 18:10:50 -0000 1.2
@@ -18,4 +18,7 @@
type="org.apache.tapestry.contrib.form.IMultiplePropertySelectionRenderer"
direction="in"/>
+ <property-specification name="name" type="java.lang.String"/>
+ <property-specification name="form" type="org.apache.tapestry.IForm"/>
+
</component-specification>
1.3 +7 -3 jakarta-tapestry/framework/src/org/apache/tapestry/IForm.java
Index: IForm.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/IForm.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IForm.java 15 Mar 2003 21:22:08 -0000 1.2
+++ IForm.java 17 Mar 2003 18:10:50 -0000 1.3
@@ -56,6 +56,7 @@
package org.apache.tapestry;
import org.apache.tapestry.form.FormEventType;
+import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.valid.IValidationDelegate;
/**
@@ -114,7 +115,7 @@
*
**/
- public String getElementId(IComponent component);
+ public String getElementId(IFormComponent component);
/**
* Constructs a unique identifier from the base id. If possible, the
@@ -125,6 +126,9 @@
* ({@link org.apache.tapestry.form.ImageSubmit}) have more specific control over
* their names.
*
+ * <p>Invokes {@link IFormComponent#setName(String)} with the result, as well
+ * as returning it.
+ *
* @throws StaleLinkException if, when the form itself is rewinding, the
* element id allocated does not match the expected id (as allocated when the form rendered).
* This indicates that the state of the application has changed between the time the
@@ -134,7 +138,7 @@
*
**/
- public String getElementId(IComponent component, String baseId);
+ public String getElementId(IFormComponent component, String baseId);
/**
* Returns the name of the form.