You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by ds...@apache.org on 2004/04/18 02:50:28 UTC
cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components When.jwc Otherwise.jwc Choose.java Choose.jwc
dsolis 2004/04/17 17:50:28
Modified: contrib/src/org/apache/tapestry/contrib/components When.jwc
Otherwise.jwc Choose.java Choose.jwc
Log:
Improve mutually exclusive conditional components
Revision Changes Path
1.3 +4 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/When.jwc
Index: When.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/When.jwc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- When.jwc 29 Feb 2004 18:49:12 -0000 1.2
+++ When.jwc 18 Apr 2004 00:50:28 -0000 1.3
@@ -31,10 +31,12 @@
</description>
</parameter>
- <parameter name="element" type="java.lang.String" direction="in" required="no">
+ <parameter name="element" type="java.lang.String" direction="in">
<description>
The element to emulate.
</description>
</parameter>
+
+ <reserved-parameter name="invert"/>
</component-specification>
1.4 +4 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Otherwise.jwc
Index: Otherwise.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Otherwise.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Otherwise.jwc 16 Apr 2004 00:28:36 -0000 1.3
+++ Otherwise.jwc 18 Apr 2004 00:50:28 -0000 1.4
@@ -25,13 +25,15 @@
and its attributes (if element is specified) .
</description>
- <parameter name="element" type="java.lang.String" direction="in" required="no">
+ <parameter name="element" type="java.lang.String" direction="in">
<description>
The element to emulate.
</description>
</parameter>
<reserved-parameter name="condition"/>
+
+ <reserved-parameter name="invert"/>
<property-specification name="condition" type="boolean" initial-value="true"/>
1.7 +16 -26 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Choose.java
Index: Choose.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Choose.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Choose.java 16 Apr 2004 00:28:36 -0000 1.6
+++ Choose.java 18 Apr 2004 00:50:28 -0000 1.7
@@ -14,11 +14,9 @@
package org.apache.tapestry.contrib.components;
-import org.apache.tapestry.AbstractComponent;
-import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRender;
import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.Tapestry;
+import org.apache.tapestry.components.Conditional;
/**
* This component is a container for {@link When} or Otherwise components;
@@ -30,7 +28,7 @@
* @version $Id$
*
**/
-public abstract class Choose extends AbstractComponent {
+public abstract class Choose extends Conditional {
public void addBody(IRender element)
@@ -40,33 +38,25 @@
((When) element).setChoose(this);
}
- /** Renders its wrapped components. */
- protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
- {
- String element = getElement();
-
- boolean render = !cycle.isRewinding() && Tapestry.isNonBlank(element);
-
- if (render)
- {
- writer.begin(element);
- renderInformalParameters(writer, cycle);
- }
-
- renderBody(writer, cycle);
-
- if (render)
- writer.end(element);
- }
-
protected void cleanupAfterRender(IRequestCycle cycle)
{
setConditionMet(false);
super.cleanupAfterRender(cycle);
}
+ protected boolean evaluateCondition()
+ {
+ return getCondition();
+ }
+
+ public boolean getInvert()
+ {
+ // This component doesn't require invert parameter.
+ return false;
+ }
+
+ public abstract boolean getCondition();
+
public abstract boolean isConditionMet();
public abstract void setConditionMet(boolean value);
-
- public abstract String getElement();
}
1.4 +10 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Choose.jwc
Index: Choose.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/components/Choose.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Choose.jwc 16 Apr 2004 00:28:36 -0000 1.3
+++ Choose.jwc 18 Apr 2004 00:50:28 -0000 1.4
@@ -25,11 +25,19 @@
Provides the context for mutually exclusive conditional evaluation.
</description>
- <parameter name="element" type="java.lang.String" direction="in" required="no">
+ <parameter name="condition" type="boolean" direction="in" default-value="true">
+ <description>
+ The condition to evaluate.
+ </description>
+ </parameter>
+
+ <parameter name="element" type="java.lang.String" direction="in">
<description>
The element to emulate.
</description>
</parameter>
+
+ <reserved-parameter name="invert"/>
<property-specification name="conditionMet" type="boolean" initial-value="false"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org