blob: 4a45db905b1c761c8265749f6ca92b374c218397 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id$ -->
<html>
<head>
<title>RenderBlock</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="RadioGroup.html"><IMG alt=RadioGroup 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="RenderBody.html"><IMG alt=RenderBody 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>RenderBlock</b></font></td>
</tr>
<tr>
<td>
<A href="../api/org/apache/tapestry/components/RenderBlock.html">
org.apache.tapestry.components.RenderBlock</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>
Renders
the text and components wrapped by the specified
<A href="Block.html">Block</A> component.
<p>
Please see the <A href="../api/org/apache/tapestry/components/RenderBlock.html">
<tt>RenderBlock</tt></A> API for a complete
discription on how the RenderBlock renders.</p>
<P>Prior to release 2.2, this component was named
<STRONG>InsertBlock</STRONG>.</P>
</td>
</tr>
<tr>
<td colspan="2">
<b>See Also</b>
<br>
<A href="Block.html">Block</A>,
<A href="Insert.html">Insert</A>,
<A href="InsertText.html">InsertText</A>,
<a href="RenderBody.html">RenderBody</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>block</td>
<td><A href="Block.html">Block</A></td>
<td>in</td>
<td>no</td>
<td>&nbsp;</td>
<td>The Block whose contents are to be rendered.</td>
</tr>
</table>
<P>Body: <STRONG>removed</STRONG><BR>Informal parameters:
<STRONG>allowed</STRONG>
<br>
Reserved
parameters: <EM>none</EM> </P>
</td>
</tr>
<tr>
<td colspan="2">
<b>Examples</b>
<p> This example shows a page with a custom TabPanel component. When
a user selects a tab, TabPanel switches content. Each tab content
is defined by a Block.</p>
<table class="tapestry-examples" border="0" width="350" cellspacing="0" cellpadding="0">
<tr>
<td width="10">&nbsp;</td>
<td>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td bgcolor="#FFFF00">
Berlin
</td> <td width="1"></td>
<td bgcolor="#CCFFFF">
Rome
</td> <td width="1"></td>
<td bgcolor="#CCFFFF">
Tokyo
</td> <td width="1"></td>
</tr>
</table>
</td>
<td width="10" >&nbsp;</td>
</tr>
<tr>
<td colspan="3" bgcolor="#00CC33" height="5">&nbsp;</td>
</tr>
<tr>
<td width="10" bgcolor="#00CC33">&nbsp;</td> <td align="center">
<H1>Berlin</H1>
</td>
<td width="10" bgcolor="#00CC33">&nbsp;</td>
</tr>
<tr>
<td colspan="3" bgcolor="#00CC33" height="5">&nbsp;</td>
</tr>
</table>
<br>
<pre>&lt;html title=&quot;TabPanel Test&quot;&gt;<br> &lt;body&gt;<br> &lt;span jwcid=&quot;@TabPanel&quot; blockNames='ognl:{&quot;Berlin&quot;, &quot;Rome&quot;, &quot;Tokyo&quot;}' selectColor=&quot;#FFFF00&quot; unSelectColor=&quot;#CCFFFF&quot; borderColor=&quot;#00CC33&quot;/&gt;<br> &lt;span jwcid=&quot;Berlin@<a href="Block.html">Block</a>&quot;&gt;<br> &lt;H1&gt;Berlin&lt;/H1&gt;<br> &lt;/span&gt;<br> &lt;span jwcid=&quot;Rome@<a href="Block.html">Block</a>&quot;&gt;<br> &lt;H1&gt;Rome&lt;/H1&gt;<br> &lt;/span&gt;<br> &lt;span jwcid=&quot;Tokyo@<a href="Block.html">Block</a>&quot;&gt;<br> &lt;H1&gt;Tokyo&lt;/H1&gt;<br> &lt;/span&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;
</pre>
<br>
TabPanel.html
<pre>&lt;table border=&quot;0&quot; width=&quot;50%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<br> &lt;tr&gt;<br> &lt;td width=&quot;10&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;td&gt;<br> &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;&gt;<br> &lt;tr&gt;<br> &lt;span jwcid=&quot;foreach@Foreach&quot; source=&quot;ognl:blockNames&quot; value=&quot;ognl:currentBlock&quot;&gt;<br> &lt;td jwcid=&quot;@Any&quot; element=&quot;td&quot; bgcolor=&quot;ognl:tabCellColor&quot;&gt;<br> &lt;a jwcid=&quot;link&quot;&gt;<br> &lt;span jwcid=&quot;@Insert&quot; value=&quot;ognl:components.foreach.value&quot;&gt;Tab Title&lt;/span&gt;<br> &lt;/a&gt;<br> &lt;/td&gt;<br> &lt;td width=&quot;1&quot;&gt;&lt;/td&gt;<br> &lt;/span&gt;<br> &lt;/tr&gt;<br> &lt;/table&gt;<br> &lt;/td&gt;<br> &lt;td width=&quot;10&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td jwcid=&quot;@Any&quot; element=&quot;td&quot; height=&quot;5&quot; bgcolor=&quot;ognl:borderColor&quot; colspan=&quot;3&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td jwcid=&quot;@Any&quot; element=&quot;td&quot; width=&quot;10&quot; bgcolor=&quot;ognl:borderColor&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;td align=&quot;center&quot;&gt;<br> &lt;span jwcid=&quot;@<a href="RenderBlock.html">RenderBlock</a>&quot; block='ognl:block'&gt;Page content goes here&lt;/span&gt;<br> &lt;/td&gt;<br> &lt;td jwcid=&quot;@Any&quot; element=&quot;td&quot; width=&quot;10&quot; bgcolor=&quot;ognl:borderColor&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td jwcid=&quot;@Any&quot; element=&quot;td&quot; height=&quot;5&quot; bgcolor=&quot;ognl:borderColor&quot; colspan=&quot;3&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;/tr&gt;<br>&lt;/table&gt;<br>
</pre>
<br>
TabPanel.jwc
<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE component-specification<br> PUBLIC &quot;-//Apache Software Foundation//Tapestry Specification 3.0//EN&quot;<br> &quot;http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd&quot;&gt;<br><br>&lt;component-specification class=&quot;spoc.components.TabPanel&quot; allow-body=&quot;no&quot; allow-informal-parameters=&quot;no&quot;&gt;<br> &lt;property-specification name=&quot;selectedBlock&quot; type=&quot;java.lang.String&quot;/&gt;<br> &lt;property-specification name=&quot;currentBlock&quot; type=&quot;java.lang.String&quot;/&gt;<br>
&lt;parameter name=&quot;blockNames&quot; direction=&quot;in&quot; type=&quot;java.util.List&quot; required=&quot;yes&quot;/&gt;<br> &lt;parameter name=&quot;borderColor&quot; direction=&quot;in&quot; type=&quot;java.lang.String&quot; required=&quot;yes&quot;/&gt;<br> &lt;parameter name=&quot;selectColor&quot; direction=&quot;in&quot; type=&quot;java.lang.String&quot; required=&quot;no&quot;/&gt;<br> &lt;parameter name=&quot;unSelectColor&quot; direction=&quot;in&quot; type=&quot;java.lang.String&quot; required=&quot;no&quot;/&gt;<br><br> &lt;component id=&quot;link&quot; type=&quot;DirectLink&quot;&gt;<br> &lt;binding name=&quot;listener&quot; expression=&quot;listeners.selectBlock&quot;/&gt;<br> &lt;binding name=&quot;parameters&quot; expression=&quot;components.foreach.value&quot;/&gt;<br> &lt;binding name=&quot;disabled&quot; expression=&quot;currentBlock == selectedBlock&quot;/&gt;<br> &lt;binding name=&quot;stateful&quot; expression=&quot;false&quot;/&gt;<br> &lt;/component&gt;<br><br>&lt;/component-specification&gt;<br>
</pre>
<br>
TabPanel.java
<pre>package com.dsconsulting.tapestry.components;
import org.apache.tapestry.BaseComponent;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.components.Block;
import java.util.List;
public abstract class TabPanel extends BaseComponent {
public static final String DEFAULT_SELECT_COLOR = &quot;#7D000D&quot;;<br> public static final String DEFAULT_UNSELECT_COLOR = &quot;#C0C0C0&quot;;<br>
private List _blockNames;<br>
public List getBlockNames() {<br> return _blockNames;<br> }<br>
public void setBlockNames(List value) {<br> _blockNames = value;<br> if (getSelectedBlock() == null) {<br> String defaultComponent = getDefaultBlock();<br> setSelectedBlock(defaultComponent);<br> setCurrentBlock(defaultComponent);<br> }<br> }<br>
public String getTabCellColor() {<br> String selectColor = getSelectColor();<br> String unSelectColor = getUnSelectColor();<br> return getCurrentBlock().equals(getSelectedBlock()) ?<br> selectColor != null ? selectColor : DEFAULT_SELECT_COLOR :<br> unSelectColor != null ? unSelectColor : DEFAULT_UNSELECT_COLOR;<br> }<br>
public void selectBlock(IRequestCycle cycle) {<br> String block = (String) cycle.getServiceParameters()[0];<br> setSelectedBlock(block);<br> fireObservedChange(&quot;selectedBlock&quot;, block);<br> }<br>
public Block getBlock() {<br> return (Block) getPage().getComponent(getSelectedBlock());<br> }<br>
public String getDefaultBlock() {<br> List tabComponents = getBlockNames();<br> return tabComponents != null ? (String)tabComponents.get(0) : null;<br> }<br>
public abstract String getSelectColor();<br> public abstract String getUnSelectColor();<br>
public abstract String getSelectedBlock();<br> public abstract void setSelectedBlock(String value);<br>
public abstract String getCurrentBlock();<br> public abstract void setCurrentBlock(String value);<br>
}
</pre>
</td>
</tr></table>
</td></tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td align="left"><A href="RadioGroup.html"><IMG alt=RadioGroup 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="RenderBody.html"><IMG alt=RenderBody src="common-images/next.png"></A></td>
</tr>
</table>
</body>
</html>