Author: jkuhnert
Date: Tue Nov 28 19:08:05 2006
New Revision: 480358
URL: http://svn.apache.org/viewvc?view=rev&rev=480358
Log:
Fixes TAPESTRY-974 .
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockDelegate.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/MockDelegate.java
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
Tue Nov 28 19:08:05 2006
@@ -111,6 +111,8 @@
_submitModes = Collections.unmodifiableSet(set);
}
+ protected final IRequestCycle _cycle;
+
/**
* Used when rewinding the form to figure to match allocated ids
(allocated during the rewind)
* against expected ids (allocated in the previous request cycle, when the
form was rendered).
@@ -124,8 +126,6 @@
*/
private final List _allocatedIds = new ArrayList();
-
- protected final IRequestCycle _cycle;
private final IdAllocator _elementIdAllocator = new IdAllocator();
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
Tue Nov 28 19:08:05 2006
@@ -85,10 +85,14 @@
delegate.writeLabelAttributes(writer, cycle, field);
renderInformalParameters(writer, cycle);
+ delegate.beforeLabelText(writer, cycle, field);
+
writer.print(displayName, getRaw());
-
+
+ delegate.afterLabelText(writer, cycle, field);
+
writer.end();
-
+
delegate.writeLabelSuffix(field, writer, cycle);
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
Tue Nov 28 19:08:05 2006
@@ -291,7 +291,7 @@
void writeLabelPrefix(IFormComponent component,
IMarkupWriter writer, IRequestCycle cycle);
-
+
/**
* Invoked just before the <label> element is closed. The delegate
can
* write additional attributes. This is often used to set the CSS class of
@@ -310,7 +310,46 @@
void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component);
-
+
+ /**
+ * Invoked just before the actual field label text is written, right after
all attributes and
+ * informal parameters are done being printed on the
<code><label></code> tag.
+ *
+ * <p>
+ * Example, writing content would go here:
+ * </p>
+ * <p>
+ * <label class="error"> >>here<< LABEL TEXT
</label>
+ * </p>
+ *
+ * @param writer
+ * The writer to use.
+ * @param cycle
+ * Current request cycle.
+ * @param component
+ * Field label is bound to.
+ */
+ void beforeLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component);
+
+ /**
+ * Invoked just before the closing <code></label></code> tag is
written.
+ *
+ * <p>
+ * Example, writing content would go here:
+ * </p>
+ * <p>
+ * <label class="error"> LABEL TEXT >>here<<
</label>
+ * </p>
+ *
+ * @param writer
+ * The writer to use.
+ * @param cycle
+ * Current request cycle.
+ * @param component
+ * Field label is bound to.
+ */
+ void afterLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component);
+
/**
* Invoked by a [EMAIL PROTECTED] FieldLabel} just after writing the name
of the form
* component.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
Tue Nov 28 19:08:05 2006
@@ -102,7 +102,21 @@
IFormComponent component)
{
}
-
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public void beforeLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public void afterLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ }
+
/**
* Closes the <font> element,started by
* [EMAIL PROTECTED]
#writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)},
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockDelegate.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockDelegate.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockDelegate.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockDelegate.java
Tue Nov 28 19:08:05 2006
@@ -124,7 +124,15 @@
{
writer.end();
}
-
+
+ public void beforeLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ }
+
+ public void afterLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ }
+
public void writeLabelPrefix(IFormComponent component, IMarkupWriter
writer, IRequestCycle cycle)
{
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
Tue Nov 28 19:08:05 2006
@@ -122,7 +122,7 @@
fl.render(writer, cycle);
-
assertBuffer("{LABEL-PREFIX}<label>FredFlintstone</label>{LABEL-SUFFIX}");
+
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}FredFlintstone{AFTER-TEXT}</label>{LABEL-SUFFIX}");
verify();
}
@@ -149,7 +149,7 @@
fl.render(writer, cycle);
-
assertBuffer("{LABEL-PREFIX}<label><b>FredFlintstone</b></label>{LABEL-SUFFIX}");
+
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}<b>FredFlintstone</b>{AFTER-TEXT}</label>{LABEL-SUFFIX}");
verify();
}
@@ -219,7 +219,7 @@
fl.render(writer, cycle);
- assertBuffer("{LABEL-PREFIX}<label>MyLabel</label>{LABEL-SUFFIX}");
+
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}MyLabel{AFTER-TEXT}</label>{LABEL-SUFFIX}");
verify();
}
@@ -253,7 +253,7 @@
fl.render(writer, cycle);
- assertBuffer("{LABEL-PREFIX}<label>MyLabel</label>{LABEL-SUFFIX}");
+
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}MyLabel{AFTER-TEXT}</label>{LABEL-SUFFIX}");
verify();
}
@@ -291,7 +291,7 @@
fl.render(writer, cycle);
- assertBuffer("{LABEL-PREFIX}<label
for=\"clientId\">MyLabel</label>{LABEL-SUFFIX}");
+ assertBuffer("{LABEL-PREFIX}<label
for=\"clientId\">{BEFORE-TEXT}MyLabel{AFTER-TEXT}</label>{LABEL-SUFFIX}");
verify();
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/MockDelegate.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/MockDelegate.java?view=diff&rev=480358&r1=480357&r2=480358
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/MockDelegate.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/MockDelegate.java
Tue Nov 28 19:08:05 2006
@@ -56,4 +56,20 @@
{
writer.print("{SUFFIX}");
}
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public void beforeLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ writer.print("{BEFORE-TEXT}");
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public void afterLabelText(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component)
+ {
+ writer.print("{AFTER-TEXT}");
+ }
}