blob: 12fd7f3ed4b9ef22c36f0ed9f5b8746f218566c4 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id$ -->
<html>
<head>
<title>Conditional</title>
<link rel="stylesheet" type="text/css" href="Tapestry.css" title="style">
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><A href="Checkbox.html"><IMG alt=Checkbox src="common-images/prev.png"></a></td>
<td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td>
<td align="right"><A href="DatePicker.html"><IMG alt="DatePicker" src="common-images/next.png"></a></td>
<tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td colspan="3">
<table border="0" cellpadding="4" cellspacing="4" width="100%">
<tr valign="top">
<td>
<table>
<tr>
<td><font size="+2"><b>Conditional</b></font></td>
</tr>
<tr>
<td>
<A href="../api/org/apache/tapestry/components/Conditional.html">org.apache.tapestry.components.Conditional</a>
</td>
</tr>
</table>
</td>
<td>
<table align="right" valign="middle" bgcolor="#c0c0c0" cellpadding="8">
<tr>
<td>Non Visual Component</td>
</tr>
</table>
</td>
</tr>
<tr valign="center">
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<b>Description</b>
<br>
Makes part of an HTML template conditional. The body of the Conditional
component is only rendered if a specified condition is met.
</td>
</tr>
<tr>
<td colspan="2">
<b>See Also</b>
<br>
<A href="Foreach.html">Foreach</a>,
<A href="Insert.html">Insert</a>
</td>
</tr>
<tr>
<td colspan="2">
<b>Parameters</b>
<br>
<table border="1" cellpadding="4" cellspacing="4" class="parameters">
<tr>
<th>Name</th>
<th>Type</th>
<th>Direction</th>
<th>Required</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td>condition</td>
<td>boolean</td>
<td>in</td>
<td>yes</td>
<td>false</td>
<td>The condition to be met. If this value is true, then the wrapped
elements will be rendered.
</td>
</tr>
<tr>
<td>invert</td>
<td>boolean</td>
<td>in</td>
<td>no</td>
<td>false</td>
<td>If true, then the condition is inverted. This is useful for
simulating an else clause.
<p>
With Tapestry 2.2 it is easier to specify "!" operator in the condition's
ONGL expression.
</p>
</td>
</tr>
<tr>
<td>element</td>
<td>String</td>
<td>in</td>
<td>no</td>
<td>&nbsp;</td>
<td>If specified and condition is satisfied, then the component acts like
an <A href="Any.html">Any</A>, emitting an open and close tag.
Informal parameters are applied to the tag. If no element is
specified, informal parameters are ignored.</td>
</tr>
</table>
<P>
Body: <STRONG>rendered</STRONG><BR>
Informal parameters: <STRONG>allowed</STRONG><br>
Reserved parameters: <EM>none</EM>
</P>
</td>
</tr>
<tr>
<td colspan="2">
<b>Examples</b>
<p>
The Conditional component in this example is used to display whether the
person is a manager and if they are a manager whether they have any staff.
<p>
<table class="examples" cellpadding="8">
<tr>
<td>
John Smith is a Manager with <font color="red"><b>no</b></font> staff.
<td></td>
</tr>
</table>
<pre>
&lt;span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:fullName"/&gt;
&lt;span jwcid="<span class="jwcid">@<a href="Conditional.html">Conditional</a></span>" condition="ognl:manager"&gt; is a Manager
&lt;span jwcid="<span class="jwcid">@<a href="Conditional.html">Conditional</a></span>" condition="ognl:! staffList.empty"&gt; with staff.&lt;/span&gt;
&lt;span jwcid="<span class="jwcid">@<a href="Conditional.html">Conditional</a></span>" condition="ognl:staffList.empty"&gt;
with &lt;font color="red"&gt;&lt;b&gt;no&lt;/b&gt;&lt;/font&gt; staff.&lt;/span&gt;
&lt;/span&gt;
&lt;span jwcid="@<a href="Conditional.html">Conditional</a>" condition="ognl:! manager"&gt; is not a Manager.&lt;/span&gt;
&lt;property-specification name=&quot;fullName&quot; type=&quot;java.lang.String&quot;/&gt;<br>&lt;property-specification name=&quot;manager&quot; type=&quot;boolean&quot;/&gt;<br>&lt;property-specification name=&quot;staffList&quot; type=&quot;java.util.List&quot;/&gt;<br>
public abstract class EnquiryPage extends BasePage {
public abstract String getFullName();
public abstract void setFullName(String value);
public abstract boolean isManager();
public abstract void setManager(boolean value);
public abstract List getStaffList();
public abstract void setStaffList(List value);
}
</pre>
</td>
</tr></table>
</td></tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td align="left"><A href="Checkbox.html"><IMG alt=Checkbox src="common-images/prev.png"></a></td>
<td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td>
<td align="right"><A href="DatePicker.html"><IMG alt="DatePicker" src="common-images/next.png"></a></td>
</tr>
</table>
</body>
</html>