You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/09/08 21:21:54 UTC
svn commit: r693207 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/corelib/components/Label.java
test/app1/SimpleForm.tml
Author: hlship
Date: Mon Sep 8 12:21:53 2008
New Revision: 693207
URL: http://svn.apache.org/viewvc?rev=693207&view=rev
Log:
TAPESTRY-2277: Removing Label body should be parameterizable
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SimpleForm.tml
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java?rev=693207&r1=693206&r2=693207&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java Mon Sep 8 12:21:53 2008
@@ -15,7 +15,9 @@
package org.apache.tapestry5.corelib.components;
import org.apache.tapestry5.*;
-import org.apache.tapestry5.annotations.*;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
@@ -50,8 +52,16 @@
private Element labelElement;
- @BeginRender
- void begin(MarkupWriter writer)
+ /**
+ * If true, then the body of the label element (in the template) is ignored. This is used when a designer places a
+ * value inside the <label> element for WYSIWYG purposes, but it should be replaced with a different
+ * (probably, localized) value at runtime. The default is false, so a body will be used if present and the field's
+ * label will only be used if the body is empty or blank.
+ */
+ @Parameter
+ private boolean ignoreBody;
+
+ boolean beginRender(MarkupWriter writer)
{
final Field field = this.field;
@@ -78,10 +88,11 @@
};
heartbeat.defer(command);
+
+ return !ignoreBody;
}
- @AfterRender
- void after(MarkupWriter writer)
+ void afterRender(MarkupWriter writer)
{
// If the Label element has a body that renders some non-blank output, that takes precendence
// over the label string provided by the field.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SimpleForm.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SimpleForm.tml?rev=693207&r1=693206&r2=693207&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SimpleForm.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SimpleForm.tml Mon Sep 8 12:21:53 2008
@@ -19,7 +19,7 @@
<t:label for="email">User Email</t:label>
<input t:type="TextField" t:id="email" value="incident.email" size="50" disabled="disabled"/>
<br/>
- <t:label for="message"/>
+ <t:label for="message" ignorebody="true">This label body is ignored.</t:label>
<input t:type="TextArea" t:id="message" label="Incident Message" value="incident.message"
cols="50" rows="10" disabled="disabled">You can put text here, but it isn't used.
</input>