Author: hlship
Date: Fri Nov 11 11:10:41 2005
New Revision: 332633
URL: http://svn.apache.org/viewcvs?rev=332633&view=rev
Log:
TAPESTRY-517: Using a FieldLabel component after the decorated form component
causes the FieldLabel's id attribute to be wrong
Added:
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
- copied, changed from r332478,
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/TestFieldLabel.java
Removed:
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/TestFieldLabel.java
Modified:
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/FieldLabel.xml
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.jwc
jakarta/tapestry/trunk/status.xml
Modified:
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/FieldLabel.xml
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/FieldLabel.xml?rev=332633&r1=332632&r2=332633&view=diff
==============================================================================
---
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/FieldLabel.xml
(original)
+++
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/FieldLabel.xml
Fri Nov 11 11:10:41 2005
@@ -94,6 +94,17 @@
the displayName includes markup text.
</td>
</tr>
+
+ <tr>
+ <td>prerender</td>
+ <td>boolean</td>
+ <td>in</td> <td>no</td> <td>true</td>
+ <td>
+ If true (the default), then the field for this label is pre-renderered.
This is necessary so that the
+ field can render itself, and set its client id (which is needed for the
FieldLabel to render).
+ When the FieldLabel is positioned <em>after</em> the field, prerender
should be set to false.
+ </td>
+ </tr>
</table>
Modified:
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java?rev=332633&r1=332632&r2=332633&view=diff
==============================================================================
---
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java
(original)
+++
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java
Fri Nov 11 11:10:41 2005
@@ -34,6 +34,9 @@
public abstract class FieldLabel extends AbstractComponent
{
+ // Parameter
+ public abstract boolean isPrerender();
+
/**
* Gets the [EMAIL PROTECTED] IForm} and [EMAIL PROTECTED]
IValidationDelegate delegate}, then renders the
* label obtained from the field. Does nothing when rewinding.
@@ -45,7 +48,7 @@
IFormComponent field = getField();
- if (field != null)
+ if (field != null && isPrerender())
form.prerenderField(writer, field, getLocation());
if (cycle.isRewinding())
Modified:
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.jwc
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.jwc?rev=332633&r1=332632&r2=332633&view=diff
==============================================================================
---
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.jwc
(original)
+++
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.jwc
Fri Nov 11 11:10:41 2005
@@ -44,6 +44,15 @@
</description>
</parameter>
+ <parameter name="prerender">
+ <description>
+ If true (the default), then the field (if any) will be pre-rendered by
the FieldLabel.
+ This is useful when the FieldLabel and field are inside a loop and the
FieldLabel
+ precedes the field. This parameter should be set to false if the
FieldLabel occurs
+ after the field.
+ </description>
+ </parameter>
+
<reserved-parameter name="for"/>
</component-specification>
Copied:
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
(from r332478,
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/TestFieldLabel.java)
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java?p2=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java&p1=jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/TestFieldLabel.java&r1=332478&r2=332633&rev=332633&view=diff
==============================================================================
---
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/TestFieldLabel.java
(original)
+++
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
Fri Nov 11 11:10:41 2005
@@ -31,47 +31,63 @@
* @author Howard M. Lewis Ship
* @since 4.0
*/
-public class TestFieldLabel extends BaseFormComponentTestCase
+public class FieldLabelTest extends BaseFormComponentTestCase
{
private IForm newForm(IValidationDelegate delegate)
{
- MockControl control = newControl(IForm.class);
- IForm form = (IForm) control.getMock();
+ IForm form = (IForm) newMock(IForm.class);
- form.getDelegate();
- control.setReturnValue(delegate);
+ trainGetDelegate(delegate, form);
return form;
}
+ private void trainGetDelegate(IValidationDelegate delegate, IForm form)
+ {
+ form.getDelegate();
+ setReturnValue(form, delegate);
+ }
+
private IPage newFred()
{
- MockControl control = newControl(IPage.class);
- IPage page = (IPage) control.getMock();
+ IPage page = (IPage) newMock(IPage.class);
- page.getPageName();
- control.setReturnValue("Fred");
+ trainGetPageName(page, "Fred");
- page.getIdPath();
- control.setReturnValue(null);
+ trainGetIdPath(page, null);
return page;
}
+ private void trainGetIdPath(IPage page, String idPath)
+ {
+ page.getIdPath();
+ setReturnValue(page, idPath);
+ }
+
private IFormComponent newField(String displayName, String clientId)
{
- MockControl control = newControl(IFormComponent.class);
- IFormComponent field = (IFormComponent) control.getMock();
+ IFormComponent field = (IFormComponent) newMock(IFormComponent.class);
- field.getDisplayName();
- control.setReturnValue(displayName);
+ trainGetDisplayName(field, displayName);
- field.getClientId();
- control.setReturnValue(clientId);
+ trainGetClientId(clientId, field);
return field;
}
+ private void trainGetClientId(String clientId, IFormComponent field)
+ {
+ field.getClientId();
+ setReturnValue(field, clientId);
+ }
+
+ private void trainGetDisplayName(IFormComponent field, String displayName)
+ {
+ field.getDisplayName();
+ setReturnValue(field, displayName);
+ }
+
public void testRewinding()
{
Location l = newLocation();
@@ -89,7 +105,7 @@
replayControls();
FieldLabel fl = (FieldLabel) newInstance(FieldLabel.class, new Object[]
- { "field", field, "location", l });
+ { "field", field, "location", l, "prerender", true });
fl.render(writer, cycle);
@@ -187,8 +203,7 @@
{
IValidationDelegate delegate = new MockDelegate();
- MockControl formc = newControl(IForm.class);
- IForm form = (IForm) formc.getMock();
+ IForm form = newForm();
IMarkupWriter writer = newBufferWriter();
IFormComponent field = newField("MyLabel", null);
@@ -201,12 +216,41 @@
trainIsRewinding(cycle, false);
FieldLabel fl = (FieldLabel) newInstance(FieldLabel.class, new Object[]
- { "location", l, "field", field });
+ { "location", l, "field", field, "prerender", true });
form.prerenderField(writer, field, l);
- form.getDelegate();
- formc.setReturnValue(delegate);
+ trainGetDelegate(form, delegate);
+
+ replayControls();
+
+ fl.render(writer, cycle);
+
+ assertBuffer("{LABEL-PREFIX}<label>MyLabel</label>{LABEL-SUFFIX}");
+
+ verifyControls();
+ }
+
+ public void testPrerenderOff()
+ {
+ IValidationDelegate delegate = new MockDelegate();
+
+ IForm form = newForm();
+
+ IMarkupWriter writer = newBufferWriter();
+ IFormComponent field = newField("MyLabel", null);
+ Location l = newLocation();
+
+ IRequestCycle cycle = newCycle();
+
+ trainGetForm(cycle, form);
+
+ trainIsRewinding(cycle, false);
+
+ FieldLabel fl = (FieldLabel) newInstance(FieldLabel.class, new Object[]
+ { "location", l, "field", field });
+
+ trainGetDelegate(form, delegate);
replayControls();
@@ -221,8 +265,7 @@
{
IValidationDelegate delegate = new MockDelegate();
- MockControl formc = newControl(IForm.class);
- IForm form = (IForm) formc.getMock();
+ IForm form = newForm();
IMarkupWriter writer = newBufferWriter();
IFormComponent field = newField("MyLabel", "clientId");
@@ -235,12 +278,11 @@
trainIsRewinding(cycle, false);
FieldLabel fl = (FieldLabel) newInstance(FieldLabel.class, new Object[]
- { "location", l, "field", field });
+ { "location", l, "field", field, "prerender", true });
form.prerenderField(writer, field, l);
- form.getDelegate();
- formc.setReturnValue(delegate);
+ trainGetDelegate(form, delegate);
replayControls();
@@ -253,13 +295,9 @@
public void testNoDisplayNameInField()
{
- MockControl formc = newControl(IForm.class);
- IForm form = (IForm) formc.getMock();
-
+ IForm form = newForm();
IMarkupWriter writer = newBufferWriter();
-
- MockControl fieldc = newControl(IFormComponent.class);
- IFormComponent field = (IFormComponent) fieldc.getMock();
+ IFormComponent field = newField();
IRequestCycle cycle = newCycle();
@@ -271,15 +309,13 @@
IPage page = newFred();
FieldLabel fl = (FieldLabel) newInstance(FieldLabel.class, new Object[]
- { "id", "label", "location", l, "field", field, "page", page,
"container", page });
+ { "id", "label", "location", l, "field", field, "page", page,
"container", page,
+ "prerender", true });
form.prerenderField(writer, field, l);
- field.getDisplayName();
- fieldc.setReturnValue(null);
-
- field.getExtendedId();
- fieldc.setReturnValue("Fred/field");
+ trainGetDisplayName(field, null);
+ trainGetExtendedId(field, "Fred/field");
replayControls();
Modified: jakarta/tapestry/trunk/status.xml
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/status.xml?rev=332633&r1=332632&r2=332633&view=diff
==============================================================================
--- jakarta/tapestry/trunk/status.xml (original)
+++ jakarta/tapestry/trunk/status.xml Fri Nov 11 11:10:41 2005
@@ -56,6 +56,7 @@
<action type="add" dev="HLS" fixes-bug="TAPESTRY-731">Extend
RequestDisplay component (used on the Exception page) to also report the
internal status of key Tapestry services</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-742">LinkSubmit renders
overly verbose JavaScript</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-620">Expose the current
IRequestCycle as an injectable service</action>
+ <action type="fix" dev="HLS" fixes-bug="TAPESTRY-517">Using a FieldLabel
component after the decorated form component causes the FieldLabel's id
attribute to be wrong</action>
</release>
<release version="4.0-beta-12" date="Oct 30 2005">
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-718">Asset injection
makes assets appear as null inside finishLoad()</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]