RadioGroup Component Index RenderBody

RenderBlock
org.apache.tapestry.components.RenderBlock
Non Visual Component
 
Description
Renders the text and components wrapped by the specified Block component.

Please see the RenderBlock API for a complete discription on how the RenderBlock renders.

Prior to release 2.2, this component was named InsertBlock.

See Also
Block, Insert, InsertText, RenderBody
Parameters
Name Type Direction Required Default Description
block Block in no   The Block whose contents are to be rendered.

Body: removed
Informal parameters: allowed
Reserved parameters: none

Examples

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.

 
Berlin Rome Tokyo
 
 
 

Berlin

 
 

<html title="TabPanel Test">
<body>
<span jwcid="@TabPanel" blockNames='ognl:{"Berlin", "Rome", "Tokyo"}' selectColor="#FFFF00" unSelectColor="#CCFFFF" borderColor="#00CC33"/>
<span jwcid="Berlin@Block">
<H1>Berlin</H1>
</span>
<span jwcid="Rome@Block">
<H1>Rome</H1>
</span>
<span jwcid="Tokyo@Block">
<H1>Tokyo</H1>
</span>
</body>
</html>

TabPanel.html
<table border="0" width="50%" cellspacing="0" cellpadding="0">
<tr>
<td width="10">&nbsp;</td>
<td>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<span jwcid="foreach@Foreach" source="ognl:blockNames" value="ognl:currentBlock">
<td jwcid="@Any" element="td" bgcolor="ognl:tabCellColor">
<a jwcid="link">
<span jwcid="@Insert" value="ognl:components.foreach.value">Tab Title</span>
</a>
</td>
<td width="1"></td>
</span>
</tr>
</table>
</td>
<td width="10">&nbsp;</td>
</tr>
<tr>
<td jwcid="@Any" element="td" height="5" bgcolor="ognl:borderColor" colspan="3">&nbsp;</td>
</tr>
<tr>
<td jwcid="@Any" element="td" width="10" bgcolor="ognl:borderColor">&nbsp;</td>
<td align="center">
<span jwcid="@RenderBlock" block='ognl:block'>Page content goes here</span>
</td>
<td jwcid="@Any" element="td" width="10" bgcolor="ognl:borderColor">&nbsp;</td>
</tr>
<tr>
<td jwcid="@Any" element="td" height="5" bgcolor="ognl:borderColor" colspan="3">&nbsp;</td>
</tr>
</table>

TabPanel.jwc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification
PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<component-specification class="spoc.components.TabPanel" allow-body="no" allow-informal-parameters="no">
<property-specification name="selectedBlock" type="java.lang.String"/>
<property-specification name="currentBlock" type="java.lang.String"/>
<parameter name="blockNames" direction="in" type="java.util.List" required="yes"/>
<parameter name="borderColor" direction="in" type="java.lang.String" required="yes"/>
<parameter name="selectColor" direction="in" type="java.lang.String" required="no"/>
<parameter name="unSelectColor" direction="in" type="java.lang.String" required="no"/>

<component id="link" type="DirectLink">
<binding name="listener" expression="listeners.selectBlock"/>
<binding name="parameters" expression="components.foreach.value"/>
<binding name="disabled" expression="currentBlock == selectedBlock"/>
<binding name="stateful" expression="false"/>
</component>

</component-specification>

TabPanel.java
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 = "#7D000D";
public static final String DEFAULT_UNSELECT_COLOR = "#C0C0C0";
private List _blockNames;
public List getBlockNames() {
return _blockNames;
}
public void setBlockNames(List value) {
_blockNames = value;
if (getSelectedBlock() == null) {
String defaultComponent = getDefaultBlock();
setSelectedBlock(defaultComponent);
setCurrentBlock(defaultComponent);
}
}
public String getTabCellColor() {
String selectColor = getSelectColor();
String unSelectColor = getUnSelectColor();
return getCurrentBlock().equals(getSelectedBlock()) ?
selectColor != null ? selectColor : DEFAULT_SELECT_COLOR :
unSelectColor != null ? unSelectColor : DEFAULT_UNSELECT_COLOR;
}
public void selectBlock(IRequestCycle cycle) {
String block = (String) cycle.getServiceParameters()[0];
setSelectedBlock(block);
fireObservedChange("selectedBlock", block);
}
public Block getBlock() {
return (Block) getPage().getComponent(getSelectedBlock());
}
public String getDefaultBlock() {
List tabComponents = getBlockNames();
return tabComponents != null ? (String)tabComponents.get(0) : null;
}
public abstract String getSelectColor();
public abstract String getUnSelectColor();
public abstract String getSelectedBlock();
public abstract void setSelectedBlock(String value);
public abstract String getCurrentBlock();
public abstract void setCurrentBlock(String value);
}

RadioGroup Component Index RenderBody