Just now had time to get back to this -- here is a patch to add the
renderTag parameter to ForBean. Updated docs and tests are included.
If attachments don't work over the list I'll create an issue and
attach the patch there.
One minor issue -- I think the logic in IfBean and ElseBean that sets
the render flag is incorrect with regard to the 'element' parameter.
The current logic is:
boolean render = !cycleRewinding && getRenderTag();
I think the presence of an element parameter should force the render,
regardless of the value of renderTag. Here's what I put in ForBean:
boolean render = !cycleRewinding && (getRenderTag() ||
HiveMind.isNonBlank(getElement()));
I don't like the extra condition, but without it upgraders could be
in for a jarring experience (especially if they turn renderTags off
with the config property).
Index:
/Users/ryan/Documents/Workspace/tapestry/src/site/xdoc/components/general/for.xml
===================================================================
---
/Users/ryan/Documents/Workspace/tapestry/src/site/xdoc/components/general/for.xml
(revision 476665)
+++
/Users/ryan/Documents/Workspace/tapestry/src/site/xdoc/components/general/for.xml
(working copy)
@@ -93,6 +93,31 @@
</tr>
<tr>
+ <td>renderTag</td>
+ <td>boolean</td>
+ <td>no</td>
+ <td>true</td>
+
+ <td>
+ Specifies whether or not to render the html tag
name used to reference this
+ component. This logic also deprecates the
<code>element</code> parameter in
+ that tag names are already captured from the html
template read in, so you
+ only need to tell the component to render or not
render whatever tag you used.
+
+ <span class="info">
+ <strong>Info:</strong>
+ <p>
+ You can also control the default value of
this property via the global
+ configuration property
<code>org.apache.tapestry.renderTags</code> which
+ is covered in more depth in the
+ <a
href="../../usersguide/configuration.html#Configuration%20Properties">configuration
section</a>
+ of the <a
href="../../usersguide/index.html">Users Guide</a>.
+ </p>
+ </span>
+ </td>
+ </tr>
+
+ <tr>
<td>element</td>
<td>String</td>
<td>no</td>
Index:
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/For.jwc
===================================================================
---
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/For.jwc
(revision 476665)
+++
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/For.jwc
(working copy)
@@ -46,6 +46,8 @@
</description>
</parameter>
+ <parameter name="renderTag" default-value="ognl:defaultRenderTags" />
+
<parameter name="element">
<description>
If provided, the component wraps its content with the requested element.
@@ -120,6 +122,7 @@
</description>
</parameter>
+ <inject property="defaultRenderTags"
object="app-property:org.apache.tapestry.renderTags" />
<inject property="dataSqueezer" object="service:tapestry.data.DataSqueezer"/>
<inject property="valueConverter"
object="service:tapestry.coerce.ValueConverter"/>
<inject property="expressionEvaluator"
object="service:tapestry.ognl.ExpressionEvaluator"/>
Index:
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java
===================================================================
---
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java
(revision 476665)
+++
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java
(working copy)
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.hivemind.HiveMind;
import org.apache.tapestry.IBinding;
import org.apache.tapestry.IForm;
import org.apache.tapestry.IMarkupWriter;
@@ -70,6 +71,8 @@
private boolean _rendering;
// parameters
+ public abstract boolean getRenderTag();
+
public abstract String getElement();
public abstract String getKeyExpression();
@@ -117,7 +120,9 @@
if (!cycleRewinding && form != null &&
!NullWriter.class.isInstance(writer))
form.setFormFieldUpdating(true);
- String element = getElement();
+ String element = HiveMind.isNonBlank(getElement()) ? getElement() :
getTemplateTagName();
+
+ boolean render = !cycleRewinding && (getRenderTag() ||
HiveMind.isNonBlank(getElement()));
// Perform the iterations
try
@@ -134,7 +139,7 @@
updateOutputParameters();
// Render component
- if (element != null)
+ if (render)
{
writer.begin(element);
renderInformalParameters(writer, cycle);
@@ -142,8 +147,8 @@
renderBody(writer, cycle);
- if (element != null)
- writer.end();
+ if (render)
+ writer.end(element);
_index++;
}
Index:
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/scripts/TestFor.xml
===================================================================
---
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/scripts/TestFor.xml
(revision 476665)
+++
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/scripts/TestFor.xml
(working copy)
@@ -53,7 +53,15 @@
<assert-output name="Test If 4">
But show this form text too!
</assert-output>
+
+ <assert-output name="Test tagsFor">
+<li informal="informal-value">Render tag</li>
+ </assert-output>
+ <assert-no-output name="Test noTagsFor">
+<li informal="informal-value">Do not render tag</li>
+ </assert-no-output>
+
</request>
<request>
Index:
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/test-data/context34/Home.html
===================================================================
---
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/test-data/context34/Home.html
(revision 476665)
+++
/Users/ryan/Documents/Workspace/tapestry/tapestry-framework/src/test-data/context34/Home.html
(working copy)
@@ -2,7 +2,7 @@
<body>
<p>
-Check the behavour of If, Else, and For.
+Check the behavior of If, Else, and For.
</p>
<span jwcid="@If" condition="ognl: !false">Show text!</span>
@@ -26,6 +26,14 @@
Rewinded value <span jwcid="@Insert" value="ognl:
components.vals.index"/> is <span jwcid="@Insert" value="ognl:
components.vals.value"/>
</span>
+ <ul>
+ <li jwcid="[EMAIL PROTECTED]" source="ognl: { '1' }" renderTag="true"
informal="informal-value">Render tag</li>
+ </ul>
+
+ <ul>
+ <li jwcid="[EMAIL PROTECTED]" source="ognl: { '1' }" renderTag="false"
informal="informal-value">Do not render tag</li>
+ </ul>
+
<span jwcid="@Form">
<span jwcid="@If" condition="ognl: !false">Show form
text!</span>
<span jwcid="@Else">Do not show form text</span>
-Ryan
On Oct 29, 2006, at 3:03 PM, Jesse Kuhnert wrote:
Thanks Ryan. I can probably add the new renderTag stuff to For
myself, but
won't be totally opposed to a patch if it includes appropriate unit
test
updates / etc as well. (thanks ? ;) I wasn't going to do the For for a
little while anyways, so if you do it that's one less thing I have
to worry
about =p )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]