blob: 46f0f76c9a6245848684f8db3bb53536fe45fdde [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>
<properties>
<title>If</title>
</properties>
<body>
<section name="If">
<p>
Conditionally emulates an element and its attributes and/or includes a block of
content if a condition is met.
</p>
<p>
<strong>
See also:
<a href="../../apidocs/org/apache/tapestry/components/IfBean.html">
org.apache.tapestry.components.IfBean
</a>
,
<a href="else.html">Else</a>
</strong>
</p>
<section name="Parameters">
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td>condition</td>
<td>boolean</td>
<td>yes</td>
<td></td>
<td>The condition to evaluate.</td>
</tr>
<tr>
<td>conditionValue</td>
<td>boolean</td>
<td>no</td>
<td></td>
<td>
The value of the condition. During render this is obtained from the
condition parameter. During rewind it is the submitted condition.
</td>
</tr>
<tr>
<td>listener</td>
<td>
<a
href="../../apidocs/org/apache/tapestry/IActionListener.html">
IActionListener
</a>
</td>
<td>no</td>
<td></td>
<td>
The listener is called before the component renders itself, regardless
of the value of the condition parameter.
</td>
</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 temlpate 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>
<td></td>
<td>
The element to emulate. If specified, 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.
<br/>
This parameter is now <em>deprecated</em> in favor of the new renderTag
parameter, the element tag to render is implied by the html used to reference
the component now.
</td>
</tr>
<tr>
<td>volatile</td>
<td>boolean</td>
<td>no</td>
<td>false</td>
<td>
Only active in a form. Determines whether to avoid creating hidden
fields within a form. Using this parameter may make the form structure
different during render and rewind, and cause exceptions as a result.
Please use with caution.
</td>
</tr>
</table>
<p>
Body:
<strong>allowed</strong>
</p>
<p>
Informal parameters:
<strong>allowed</strong>
</p>
<p>
Reserved parameters:
<em>name</em>
,
<em>form</em>
</p>
</section>
<section name="Examples">
<p>
In this example we say hello to our user if he/she has login, or we ask him/her
login.
</p>
<p>Home.html</p>
<source xml:space="preserve">
...
&lt;p&gt;
Hello, &lt;span jwcid="@If" condition="ognl:user.login"&gt;&lt;span jwcid="@Insert" value="ognl:user.name"/&gt;&lt;/span&gt;
&lt;span jwcid="@Else"&gt;please &lt;span jwcid="@PageLink" page="Login"&gt;login&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
...
</source>
</section>
</section>
</body>
</document>