Tabbox Renderer"
From Documentation
Jumperchen (talk | contribs) (Created page with "{{ZKDevelopersReferencePageHeader}} [Since 7.0.0] Here we describe how to implement a custom renderer for a tabbox (<javadoc type="interface">org.zkoss.zul.TabboxRenderer</java...") |
m (remove empty version history (via JWB)) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
− | + | {{ZK EE}} | |
+ | {{versionSince|7.0.0}} | ||
Here we describe how to implement a custom renderer for a tabbox (<javadoc type="interface">org.zkoss.zul.TabboxRenderer</javadoc>). For the concepts about component, model and renderer, please refer to [[ZK_Developer's_Reference/MVC/Model/List_Model#Model-driven_Display|the Model-driven Display section]]. | Here we describe how to implement a custom renderer for a tabbox (<javadoc type="interface">org.zkoss.zul.TabboxRenderer</javadoc>). For the concepts about component, model and renderer, please refer to [[ZK_Developer's_Reference/MVC/Model/List_Model#Model-driven_Display|the Model-driven Display section]]. | ||
− | When a tabbox (<javadoc>org.zkoss.zul.Tabbox</javadoc>) is assigned with a model, a default renderer is assigned too. The default renderer will assume that each tab has only one tabpanel, and it converts the data into a string directly<ref>If the tabbox is assigned a template called < | + | When a tabbox (<javadoc>org.zkoss.zul.Tabbox</javadoc>) is assigned with a model, a default renderer is assigned too. The default renderer will assume that each tab has only one tabpanel, and it converts the data into a string directly<ref>If the tabbox is assigned a template called <code>model:tab</code> and <code>model:tabpanel</code>, then the template will be used to render the tabbox. For more information, please refer to [[ZK Developer's Reference/MVC/View/Template/Tabbox Template|the Tabbox Template section]].</ref>. If you want to display a rich tabpanel or retrieve a particular field of the data, you have to implement <javadoc type="interface">org.zkoss.zul.TabboxRenderer</javadoc> to handle the rendering. |
For example, | For example, | ||
Line 24: | Line 25: | ||
</blockquote> | </blockquote> | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{ZKDevelopersReferencePageFooter}} | {{ZKDevelopersReferencePageFooter}} |
Latest revision as of 04:38, 5 February 2024
- Available for ZK:
Since 7.0.0 Here we describe how to implement a custom renderer for a tabbox (TabboxRenderer). For the concepts about component, model and renderer, please refer to the Model-driven Display section.
When a tabbox (Tabbox) is assigned with a model, a default renderer is assigned too. The default renderer will assume that each tab has only one tabpanel, and it converts the data into a string directly[1]. If you want to display a rich tabpanel or retrieve a particular field of the data, you have to implement TabboxRenderer to handle the rendering.
For example,
public class MyRenderer implements TabboxRenderer{
public void renderTab(Tab tab, Object data, int index) {
tab.setLabel("New -- " + data);
}
public void renderTabpanel(Tabpanel tabpanel, Object data, int index) {
tabpanel.appendChild(new Label("New -- " + data));
}
}
- ↑ If the tabbox is assigned a template called
model:tab
andmodel:tabpanel
, then the template will be used to render the tabbox. For more information, please refer to the Tabbox Template section.