Author: ilya_shaikovsky
Date: 2010-12-31 05:16:36 -0500 (Fri, 31 Dec 2010)
New Revision: 20856
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
Log:
https://issues.jboss.org/browse/RF-9833
+ fileUpload sources added
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-31
10:16:36 UTC (rev 20856)
@@ -33,6 +33,7 @@
import javax.faces.bean.ManagedProperty;
import javax.swing.tree.TreeNode;
+import org.richfaces.component.UITree;
import org.richfaces.demo.tree.model.CD;
import org.richfaces.demo.tree.model.Company;
import org.richfaces.demo.tree.model.Country;
@@ -50,7 +51,8 @@
private List<TreeNode> rootNodes = new ArrayList<TreeNode>();
private Map<String, Country> countriesCache = new HashMap<String,
Country>();
private Map<String, Company> companiesCache = new HashMap<String,
Company>();
- private Object currentSelection;
+ private TreeNode currentSelection = null;
+
@PostConstruct
public void init() {
for (CDXmlDescriptor current : cdXmlDescriptors) {
@@ -62,12 +64,17 @@
company.getCds().add(cd);
}
}
-
- public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent){
- //considering only single selection
+
+ public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent) {
+ // considering only single selection
List<Object> selection = new
ArrayList<Object>(selectionChangeEvent.getNewSelection());
- currentSelection = selection.get(0);
-
+ Object currentSelectionKey = selection.get(0);
+ UITree tree = (UITree) selectionChangeEvent.getSource();
+
+ Object storedKey = tree.getRowKey();
+ tree.setRowKey(currentSelectionKey);
+ currentSelection = (TreeNode) tree.getRowData();
+ tree.setRowKey(storedKey);
}
private Country getCountryByName(CDXmlDescriptor descriptor) {
@@ -111,4 +118,12 @@
this.rootNodes = rootNodes;
}
+ public TreeNode getCurrentSelection() {
+ return currentSelection;
+ }
+
+ public void setCurrentSelection(TreeNode currentSelection) {
+ this.currentSelection = currentSelection;
+ }
+
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java 2010-12-31
10:16:36 UTC (rev 20856)
@@ -7,24 +7,31 @@
public class CD extends NamedNode implements TreeNode {
private Company company;
private String artist;
- private String title;
private float price;
private int year;
public CD() {
this.setType("cd");
}
-
- public CD(String title, String artist, Company company, float price, int year) {
+
+ public CD(String name, String artist, Company company, float price, int year) {
super();
this.setType("cd");
this.company = company;
this.artist = artist;
- this.title = title;
+ this.name = name;
this.price = price;
this.year = year;
}
+ public Company getCompany() {
+ return company;
+ }
+
+ public void setCompany(Company company) {
+ this.company = company;
+ }
+
public TreeNode getChildAt(int childIndex) {
return null;
}
@@ -70,14 +77,6 @@
this.artist = artist;
}
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
public float getPrice() {
return price;
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java 2010-12-31
10:16:36 UTC (rev 20856)
@@ -9,10 +9,9 @@
import com.google.common.collect.Iterators;
public class Company extends NamedNode implements TreeNode {
- private String name;
private List<CD> cds = new ArrayList<CD>();
private Country country;
-
+
public Company() {
this.setType("company");
}
@@ -49,14 +48,6 @@
return Iterators.asEnumeration(cds.iterator());
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public Country getCountry() {
return country;
}
@@ -68,5 +59,5 @@
public List<CD> getCds() {
return cds;
}
-
+
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java 2010-12-31
10:16:36 UTC (rev 20856)
@@ -10,7 +10,6 @@
public class Country extends NamedNode implements TreeNode {
- private String name;
private List<Company> companies = new ArrayList<Company>();
public Country() {
@@ -45,14 +44,6 @@
return Iterators.asEnumeration(companies.iterator());
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public List<Company> getCompanies() {
return companies;
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java 2010-12-31
10:16:36 UTC (rev 20856)
@@ -2,9 +2,18 @@
import java.io.Serializable;
-public class NamedNode implements Serializable{
- private String type;
+public class NamedNode implements Serializable {
+ protected String type;
+ protected String name;
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
public String getType() {
return type;
}
@@ -12,4 +21,9 @@
public void setType(String type) {
this.type = type;
}
+
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-31
10:16:36 UTC (rev 20856)
@@ -172,10 +172,21 @@
</demo>
</demos>
</group>
- <!-- group> <name>Validation</name> <demos> <demo>
<id>clientValidation</id>
- <name>Ajax/Client Validation</name> <samples> <sample>
<id>ajaxValidation</id>
- <name>Simple Ajax Validation</name> </sample> </samples>
</demo> </demos>
- </group -->
+ <!-- group>
+ <name>Validation</name>
+ <demos>
+ <demo new="true">
+ <id>clientValidation</id>
+ <name>Ajax/Client Validation</name>
+ <samples>
+ <sample>
+ <id>simple</id>
+ <name>Simple Ajax Validation</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group-->
<group>
<name>Data Iteration</name>
<demos>
@@ -281,11 +292,11 @@
<group>
<name>Trees</name>
<demos>
- <demo>
+ <demo new="true">
<id>tree</id>
<name>rich:tree</name>
<samples>
- <sample>
+ <sample new="true">
<id>tree</id>
<name>Simple tree from XML</name>
</sample>
@@ -300,7 +311,7 @@
<name>Simple treeModelRecursiveAdaptor usage</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
<group>
@@ -545,25 +556,25 @@
<name>Upload images</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
- <group>
- <name>Drag and Drop</name>
- <demos>
- <demo new="true">
- <id>dragDrop</id>
- <name>Drag and Drop</name>
- <samples>
- <sample>
- <id>dragDrop</id>
- <name>Drag and Drop usage example</name>
- </sample>
- </samples>
- </demo>
- </demos>
- </group>
<group>
+ <name>Drag and Drop</name>
+ <demos>
+ <demo new="true">
+ <id>dragDrop</id>
+ <name>Drag and Drop</name>
+ <samples>
+ <sample>
+ <id>dragDrop</id>
+ <name>Drag and Drop usage example</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
<name>Misc Components/Features</name>
<demos>
<demo>
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml 2010-12-31
10:16:36 UTC (rev 20856)
@@ -24,6 +24,12 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/fileupload/FileUploadBean.java"/>
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View FileUploadBean.java"
/>
+ <ui:param name="hideLabel" value="Hide FileUploadBean.java"
/>
+ </ui:include>
<p><b>FileUpload requires two context-parameter's to be set in
web.xml:</b></p>
<ul>
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-31
08:29:12 UTC (rev 20855)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-31
10:16:36 UTC (rev 20856)
@@ -5,18 +5,55 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
-
- <rich:tree id="tree" nodeType="#{node.type}"
var="node"
- value="#{treeBean.rootNodes}" toggleType="client"
- >
- <rich:treeNode type="country">
+ <style>
+ .top{
+ vertical-align: top;
+ width: 50%;
+ }
+ .bold{
+ font-weight: bold;
+ }
+ </style>
+ <h:panelGrid columns="2" columnClasses="top,top"
width="60%">
+ <h:form>
+ <rich:tree id="tree" nodeType="#{node.type}"
var="node"
+ value="#{treeBean.rootNodes}" toggleType="client"
+ selectionType="ajax"
+ selectionChangeListener="#{treeBean.selectionChanged}">
+ <rich:treeNode type="country">
#{node.name}
</rich:treeNode>
- <rich:treeNode type="company" icon="/images/tree/disc.gif">
+ <rich:treeNode type="company"
icon="/images/tree/disc.gif">
#{node.name}
</rich:treeNode>
- <rich:treeNode type="cd" icon="/images/tree/song.gif">
- #{node.artist} - #{node.title} - #{node.year}
+ <rich:treeNode type="cd" icon="/images/tree/song.gif">
+ #{node.artist} - #{node.name} - #{node.year}
</rich:treeNode>
- </rich:tree>
+ </rich:tree>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true" layout="block">
+ <rich:panel header="Current Selection"
+ rendered="#{not empty treeBean.currentSelection}">
+ <h:outputText value="Name:" />
+ <h:outputText value="#{treeBean.currentSelection.name}" />
+ <h:panelGroup rendered="#{treeBean.currentSelection.leaf}">
+ <fieldset><legend>Details</legend> <h:panelGrid
columnClasses="bold"
+ columns="2">
+ <h:outputText value="Country:" />
+ <h:outputText value="#{treeBean.currentSelection.company.country}"
/>
+ <h:outputText value="Company:" />
+ <h:outputText value="#{treeBean.currentSelection.company}" />
+ <h:outputText value="Artist:" />
+ <h:outputText value="#{treeBean.currentSelection.artist}" />
+ <h:outputText value="Price:" />
+ <h:outputText value="#{treeBean.currentSelection.price}">
+ <f:convertNumber type="currency" currencyCode="USD"/>
+ </h:outputText>
+ <h:outputText value="Year:" />
+ <h:outputText value="#{treeBean.currentSelection.year}" />
+ </h:panelGrid></fieldset>
+ </h:panelGroup>
+ </rich:panel>
+ </a4j:outputPanel>
+ </h:panelGrid>
</ui:composition>
\ No newline at end of file
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml 2010-12-31
08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml 2010-12-31
10:16:36 UTC (rev 20856)
@@ -5,15 +5,17 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
- <p><b>rich:tree</b> is a component that renders a tree control on the
page. The
- most important tree features are:</p>
- <ul>
+ <p><b>rich:tree</b> is a component that renders a tree control on
+ the page. The most important tree features are:</p>
+ <ul>
<li>Native support for Ajax operations</li>
<li>Support for "ajax", "client" and "server"
switch types</li>
<li>Selection capabilities</li>
<li>Flexible look</li>
</ul>
-
+ <p>This demo also provides simple selection handling sample. When
+ you will select some node its name will be shown. And when you will
+ select a leaf - full CD details will be populated.</p>
<ui:include src="#{demoNavigator.sampleIncludeURI}" />
<ui:include src="/templates/includes/source-view.xhtml">
<ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
@@ -21,6 +23,37 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tree/TreeBean.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View TreeBean.java" />
+ <ui:param name="hideLabel" value="Hide TreeBean.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tree/model/Country.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View Country.java" />
+ <ui:param name="hideLabel" value="Hide Country.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tree/model/Company.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View Company.java" />
+ <ui:param name="hideLabel" value="Hide Company.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tree/model/CD.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CD.java" />
+ <ui:param name="hideLabel" value="Hide CD.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tree/model/NamedNode.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View NamedNode.java" />
+ <ui:param name="hideLabel" value="Hide NamedNode.java" />
+ </ui:include>
+
</ui:composition>
</html>
\ No newline at end of file