[richfaces-svn-commits] JBoss Rich Faces SVN: r11717 - in trunk/samples/richfaces-demo/src/main: webapp/WEB-INF and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Dec 11 09:32:53 EST 2008


Author: ilya_shaikovsky
Date: 2008-12-11 09:32:53 -0500 (Thu, 11 Dec 2008)
New Revision: 11717

Added:
   trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/SelectsBean.java
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/dropDowns.xhtml
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/examples/dynamicSelects.xhtml
Modified:
   trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/support.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-5147

Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/SelectsBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/SelectsBean.java	                        (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/SelectsBean.java	2008-12-11 14:32:53 UTC (rev 11717)
@@ -0,0 +1,69 @@
+package org.richfaces.demo.ajaxsupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.model.SelectItem;
+
+public class SelectsBean {
+		private String currentType="";
+		private String currentItem="";
+		public List<SelectItem> firstList = new ArrayList<SelectItem>(); 
+		public List<SelectItem> secondList = new ArrayList<SelectItem>();
+		private static final String [] FRUITS = {"Banana", "Cranberry", "Blueberry", "Orange"};
+		private static final String [] VEGETABLES = {"Potatoes", "Broccoli", "Garlic", "Carrot"};
+		
+		public SelectsBean() {
+			SelectItem item = new SelectItem("fruits", "Fruits");
+			firstList.add(item);
+			item = new SelectItem("vegetables", "Vegetables");
+			firstList.add(item);
+			for (int i = 0; i < FRUITS.length; i++) {
+				item = new SelectItem(FRUITS[i]);
+			}
+		}
+		
+		public List<SelectItem> getFirstList() {
+			return firstList;
+		}
+		public List<SelectItem> getSecondList() {
+			return secondList;
+		}
+		public static String[] getFRUITS() {
+			return FRUITS;
+		}
+		public static String[] getVEGETABLES() {
+			return VEGETABLES;
+		}
+		public void valueChanged(ValueChangeEvent event){
+			secondList.clear();
+			String[] currentItems;
+			if (((String)event.getNewValue()).equals("fruits")) {
+				currentItems = FRUITS;
+			}else{
+				currentItems = VEGETABLES;
+			}
+			for (int i = 0; i < currentItems.length; i++) {
+				SelectItem item = new SelectItem(currentItems[i]);
+				secondList.add(item);
+			}
+				
+		}
+
+		public String getCurrentType() {
+			return currentType;
+		}
+
+		public void setCurrentType(String currentType) {
+			this.currentType = currentType;
+		}
+
+		public String getCurrentItem() {
+			return currentItem;
+		}
+
+		public void setCurrentItem(String currentItem) {
+			this.currentItem = currentItem;
+		}
+}

Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml	2008-12-11 11:50:45 UTC (rev 11716)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml	2008-12-11 14:32:53 UTC (rev 11717)
@@ -418,6 +418,11 @@
   <managed-bean-class>org.richfaces.demo.queue.MojarraBean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
  </managed-bean>
+ <managed-bean>
+  <managed-bean-name>selectsBean</managed-bean-name>
+  <managed-bean-class>org.richfaces.demo.ajaxsupport.SelectsBean</managed-bean-class>
+  <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
  <navigation-rule>
   <from-view-id>/richfaces/include/examples/wstep1.xhtml</from-view-id>
   <navigation-case>

Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/dropDowns.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/dropDowns.xhtml	                        (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/dropDowns.xhtml	2008-12-11 14:32:53 UTC (rev 11717)
@@ -0,0 +1,40 @@
+<!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:ui="http://java.sun.com/jsf/facelets"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:a4j="http://richfaces.org/a4j"
+	xmlns:rich="http://richfaces.org/rich">
+	<ui:composition  template="/templates/component-sample.xhtml">
+		<ui:define name="sample">
+			
+			<p>
+				One of the most frequently asked question from the community is about the
+				problems while trying to create so called dependent selects. 
+			</p>
+			<p>
+				So there you could explore simple sample of this case and check the source
+				code used.
+			</p>
+			<p>
+				After you select the produce type - the second select list will be populated 
+				and contains the items of this type. And if you change the type it will
+				be updated again wih proper values. 
+			</p>
+			
+			<fieldset class="demo_fieldset">
+				<legend class="demo_legend">Dynamic selects Demo</legend>
+					<div class="sample-container" >
+
+						<ui:include src="/richfaces/support/examples/dynamicSelects.xhtml"/>
+						<ui:include src="/templates/include/sourceview.xhtml">
+							<ui:param name="sourcepath" value="/richfaces/support/examples/dynamicSelects.xhtml"/>
+						</ui:include>			
+
+								
+					</div>
+			</fieldset>
+		</ui:define>
+
+	</ui:composition>
+</html>

Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/examples/dynamicSelects.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/examples/dynamicSelects.xhtml	                        (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/support/examples/dynamicSelects.xhtml	2008-12-11 14:32:53 UTC (rev 11717)
@@ -0,0 +1,24 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core"
+      xmlns:a4j="http://richfaces.org/a4j"
+      xmlns:rich="http://richfaces.org/rich">
+	<h:form>
+		<h:panelGrid columns="2">
+			<h:outputText value="Choose the produce type:"/>
+			<rich:inplaceSelect value="#{selectsBean.currentType}" valueChangeListener="#{selectsBean.valueChanged}" defaultLabel="Click here to select">
+				<f:selectItems value="#{selectsBean.firstList}"/>
+				<a4j:support event="onchange" reRender="items, label" ajaxSingle="true"/>
+			</rich:inplaceSelect>
+			<a4j:outputPanel id="label">
+				<h:outputText value="Choose concrete product:" rendered="#{!empty selectsBean.secondList}"/>
+			</a4j:outputPanel> 	
+			<a4j:outputPanel id="items">
+				<rich:inplaceSelect value="#{selectsBean.currentItem}" rendered="#{!empty selectsBean.secondList}" defaultLabel="Click here to select">
+					<f:selectItems value="#{selectsBean.secondList}"/>
+				</rich:inplaceSelect>
+			</a4j:outputPanel>
+		</h:panelGrid>
+	</h:form>
+</ui:composition>

Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/support.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/support.xhtml	2008-12-11 11:50:45 UTC (rev 11716)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/support.xhtml	2008-12-11 14:32:53 UTC (rev 11717)
@@ -7,7 +7,20 @@
 <ui:composition template="/templates/main.xhtml">
 	<ui:define name="title">RichFaces - Open Source Rich JSF Components - Ajax Support</ui:define>
 	<ui:define name="body">
-		<ui:include src="/templates/include/tab-panel.xhtml" />
+		<rich:tabPanel switchType="server" styleClass="top_tab" contentClass="content_tab" headerClass="header_tabs_class" inactiveTabClass="inactive_tab" activeTabClass="active_tab"
+		selectedTab="#{componentNavigator.currentComponent.activeTab}" valueChangeListener="#{componentNavigator.tabPanelSwitched}">
+			<rich:tab label="Usage" name="usage">
+				<ui:include src="/richfaces/support/usage.xhtml"/>
+			</rich:tab>			
+			<rich:tab label="Dynamic Forms Sample" name="selects">
+				<ui:include src="/richfaces/support/dropDowns.xhtml"/>
+			</rich:tab>			 
+			<rich:tab name="info" label="Tag Information">
+				<rich:insert
+					src="/WEB-INF/#{componentNavigator.currentComponent.tagInfoLocation}"
+					errorContent="/templates/include/tagInfoNotes.xhtml" />
+			</rich:tab>	
+		</rich:tabPanel>
 	</ui:define>
 	</ui:composition>
 </html>




More information about the richfaces-svn-commits mailing list