Author: jjamrich
Date: 2011-05-19 12:19:25 -0400 (Thu, 19 May 2011)
New Revision: 22501
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/list.xhtml
Log:
RFPL-1445: Another way to create tab dynamically
Added new page with example of dynamic tab using predefined rich:tab
component with dynamically generated atributes
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java 2011-05-19
07:47:18 UTC (rev 22500)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java 2011-05-19
16:19:25 UTC (rev 22501)
@@ -50,6 +50,7 @@
private Attributes attributes;
private List<UITab> tabs = new ArrayList<UITab>();
+ private List<TabBean> tabBeans = new ArrayList<TabBean>();
/**
* Initializes the managed bean.
@@ -85,6 +86,18 @@
tabs.add(tab);
}
+
+ public void generateNewTab() {
+
+ System.out.println(" ###### adding new tabBean... ");
+
+ int i = tabBeans.size();
+ String idBase = "tab" + (i + 6); // there is already 5 tabs
+ tabBeans.add(new TabBean(idBase, idBase, idBase + " header",
+ "Content of dynamicaly created " + idBase));
+
+ System.out.println(" Now is tabBeans list " + tabBeans.size() + "
long");
+ }
public Attributes getAttributes() {
return attributes;
@@ -101,4 +114,60 @@
public void setTabs(List<UITab> tabs) {
this.tabs = tabs;
}
+
+ public class TabBean {
+ private String tabId;
+ private String tabName;
+ private String tabHeader;
+ private String tabContentText;
+
+ public TabBean(String tabId, String tabName, String tabHeader,
+ String tabContentText){
+ this.tabId = tabId;
+ this.tabName = tabName;
+ this.tabHeader = tabHeader;
+ this.tabContentText = tabContentText;
+ }
+
+ public String getTabId() {
+ return tabId;
+ }
+
+ public void setTabId(String tabId) {
+ this.tabId = tabId;
+ }
+
+ public String getTabName() {
+ return tabName;
+ }
+
+ public void setTabName(String tabName) {
+ this.tabName = tabName;
+ }
+
+ public String getTabHeader() {
+ return tabHeader;
+ }
+
+ public void setTabHeader(String tabHeader) {
+ this.tabHeader = tabHeader;
+ }
+
+ public String getTabContentText() {
+ return tabContentText;
+ }
+
+ public void setTabContentText(String tabContentText) {
+ this.tabContentText = tabContentText;
+ }
+
+ }
+
+ public List<TabBean> getTabBeans() {
+ return tabBeans;
+ }
+
+ public void setTabBeans(List<TabBean> tabBeans) {
+ this.tabBeans = tabBeans;
+ }
}
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml 2011-05-19
16:19:25 UTC (rev 22501)
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core" >
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:tabPanel id="tabPanel"
+
activeItem="#{richTabPanelBean.attributes['activeItem'].value}"
+
cycledSwitching="#{richTabPanelBean.attributes['cycledSwitching'].value}"
+
dir="#{richTabPanelBean.attributes['dir'].value}"
+
headerAlignment="#{richTabPanelBean.attributes['headerAlignment'].value}"
+
headerPosition="#{richTabPanelBean.attributes['headerPosition'].value}"
+
immediate="#{richTabPanelBean.attributes['immediate'].value}"
+ itemChangeListener="#{richBean.itemChangeListener}"
+
lang="#{richTabPanelBean.attributes['lang'].value}"
+
onbeforeitemchange="#{richTabPanelBean.attributes['onbeforeitemchange'].value}"
+
onclick="#{richTabPanelBean.attributes['onclick'].value}"
+
ondblclick="#{richTabPanelBean.attributes['ondblclick'].value}"
+
onitemchange="#{richTabPanelBean.attributes['onitemchange'].value}"
+
onmousedown="#{richTabPanelBean.attributes['onmousedown'].value}"
+
onmousemove="#{richTabPanelBean.attributes['onmousemove'].value}"
+
onmouseout="#{richTabPanelBean.attributes['onmouseout'].value}"
+
onmouseover="#{richTabPanelBean.attributes['onmouseover'].value}"
+
onmouseup="#{richTabPanelBean.attributes['onmouseup'].value}"
+
rendered="#{richTabPanelBean.attributes['rendered'].value}"
+
style="#{richTabPanelBean.attributes['style'].value}"
+
styleClass="#{richTabPanelBean.attributes['styleClass'].value}"
+
switchType="#{richTabPanelBean.attributes['switchType'].value}"
+
tabActiveHeaderClass="#{richTabPanelBean.attributes['tabActiveHeaderClass'].value}"
+
tabContentClass="#{richTabPanelBean.attributes['tabContentClass'].value}"
+
tabDisabledHeaderClass="#{richTabPanelBean.attributes['tabDisabledHeaderClass'].value}"
+
tabHeaderClass="#{richTabPanelBean.attributes['tabHeaderClass'].value}"
+
tabInactiveHeaderClass="#{richTabPanelBean.attributes['tabInactiveHeaderClass'].value}"
+
title="#{richTabPanelBean.attributes['title'].value}"
+ >
+
+ <rich:tab id="tab1" name="tab1" header="tab1
header">
+ content of tab 1
+ </rich:tab>
+ <rich:tab id="tab2" name="tab2" header="tab2
header">
+ content of tab 2
+ </rich:tab>
+ <rich:tab id="tab3" name="tab3" header="tab3
header">
+ content of tab 3
+ </rich:tab>
+ <rich:tab id="tab4" name="tab4" header="tab4
header" disabled="true">
+ content of tab 4
+ </rich:tab>
+ <rich:tab id="tab5" name="tab5" header="tab5
header">
+ content of tab 5
+ </rich:tab>
+
+ <c:forEach items="#{richTabPanelBean.tabBeans}"
var="newTab">
+ <rich:tab id="#{newTab.tabId}"
name="#{newTab.tabName}" header="#{newTab.tabHeader}">
+ #{newTab.tabContentText}
+ </rich:tab>
+ </c:forEach>
+
+ </rich:tabPanel>
+
+ <br/><br/>
+ <fieldset>
+ <legend>JavaScript API</legend>
+
+ <script type="text/javascript">
+ testedComponentId =
"#{rich:clientId('tabPanel')}";
+ </script>
+
+ <h:commandButton id="switchButton1" value="switch to
tab1">
+ <rich:componentControl event="click"
operation="switchToItem" target="tabPanel" >
+ <f:param value="tab1" />
+ </rich:componentControl>
+ </h:commandButton>
+ <h:commandButton id="switchButton2" value="switch to
tab2">
+ <rich:componentControl event="click"
operation="switchToItem" target="tabPanel" >
+ <f:param value="tab2" />
+ </rich:componentControl>
+ </h:commandButton>
+ <h:commandButton id="switchButton3" value="switch to
tab3">
+ <rich:componentControl event="click"
operation="switchToItem" target="tabPanel" >
+ <f:param value="tab3" />
+ </rich:componentControl>
+ </h:commandButton>
+ <h:commandButton id="switchButton4" value="switch to
tab4">
+ <rich:componentControl event="click"
operation="switchToItem" target="tabPanel" >
+ <f:param value="tab4" />
+ </rich:componentControl>
+ </h:commandButton>
+ <h:commandButton id="switchButton5" value="switch to
tab5">
+ <rich:componentControl event="click"
operation="switchToItem" target="tabPanel" >
+ <f:param value="tab5" />
+ </rich:componentControl>
+ </h:commandButton>
+
+ <h:commandButton id="hCreateTabButton" value="[h]
Create tab"
+ actionListener="#{richTabPanelBean.generateNewTab}"
/>
+ <a4j:commandButton id="a4jCreateTabButton" value="[a4j]
Create tab"
+ render="tabPanel"
+ actionListener="#{richTabPanelBean.generateNewTab}"
/>
+
+ </fieldset>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richTabPanelBean.attributes}"
id="attributes" render="log"/>
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/list.xhtml 2011-05-19
07:47:18 UTC (rev 22500)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/list.xhtml 2011-05-19
16:19:25 UTC (rev 22501)
@@ -35,7 +35,11 @@
Simple page containing <b>rich:tabPanel</b> and input boxes
for all its attributes.
</metamer:testPageLink>
- <metamer:testPageLink id="addTab" outcome="addTab"
value="Simple">
+ <metamer:testPageLink id="addTab" outcome="addTab"
value="Add tab v1">
+ Simple page containing <b>rich:tabPanel</b> and buttons for
create new tabs using binding
+ </metamer:testPageLink>
+
+ <metamer:testPageLink id="addTab2" outcome="addTab2"
value="Add tab v2">
Simple page containing <b>rich:tabPanel</b> and buttons for
create new tabs
</metamer:testPageLink>