Author: ilya_shaikovsky
Date: 2010-08-17 10:57:20 -0400 (Tue, 17 Aug 2010)
New Revision: 18710
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tables/ExtTableSelectionBean.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelection-sample.xhtml
Removed:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelectionSample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/exTableSelection.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/simpleTable-sample.xhtml
Log:
https://jira.jboss.org/browse/RF-9092
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tables/ExtTableSelectionBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tables/ExtTableSelectionBean.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tables/ExtTableSelectionBean.java 2010-08-17
14:57:20 UTC (rev 18710)
@@ -0,0 +1,59 @@
+package org.richfaces.demo.tables;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.event.AjaxBehaviorEvent;
+
+import org.richfaces.component.UIExtendedDataTable;
+import org.richfaces.demo.tables.model.cars.InventoryItem;
+
+@ManagedBean
+@SessionScoped
+public class ExtTableSelectionBean {
+ private Collection<Object> selection;
+ @ManagedProperty(value = "#{carsBean.allInventoryItems}")
+ private List<InventoryItem> inventoryItems;
+ private List<InventoryItem> selectionItems = new
ArrayList<InventoryItem>();
+
+ public void selectionListener(AjaxBehaviorEvent event){
+ UIExtendedDataTable dataTable = (UIExtendedDataTable)event.getComponent();
+ Object originalKey = dataTable.getRowKey();
+ selectionItems.clear();
+ for (Object selectionKey: selection) {
+ dataTable.setRowKey(selectionKey);
+ if (dataTable.isRowAvailable()){
+ selectionItems.add((InventoryItem)dataTable.getRowData());
+ }
+ }
+ dataTable.setRowKey(originalKey);
+ }
+
+ public Collection<Object> getSelection() {
+ return selection;
+ }
+
+ public void setSelection(Collection<Object> selection) {
+ this.selection = selection;
+ }
+
+ public List<InventoryItem> getInventoryItems() {
+ return inventoryItems;
+ }
+
+ public void setInventoryItems(List<InventoryItem> inventoryItems) {
+ this.inventoryItems = inventoryItems;
+ }
+
+ public List<InventoryItem> getSelectionItems() {
+ return selectionItems;
+ }
+
+ public void setSelectionItems(List<InventoryItem> selectionItems) {
+ this.selectionItems = selectionItems;
+ }
+}
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-08-17
13:41:49 UTC (rev 18709)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-08-17
14:57:20 UTC (rev 18710)
@@ -238,6 +238,10 @@
<id>simpleTable</id>
<name>ExtendedData Table Basic Usage</name>
</sample>
+ <sample>
+ <id>exTableSelection</id>
+ <name>ExtendedData Table Selection usage</name>
+ </sample>
</samples>
</demo>
<demo>
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/exTableSelection.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/exTableSelection.xhtml 2010-08-17
13:41:49 UTC (rev 18709)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/exTableSelection.xhtml 2010-08-17
14:57:20 UTC (rev 18710)
@@ -5,13 +5,18 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
- <p>ExtendedDataTable component provides next set of features:</p>
- <ul>
- <li>Horizontal/Vertical scrolling</li>
- <li>Ajax lazy loading on vertical scroll</li>
- <li>Support "frozen" columns which are not scrolled on using
- horizontal scroll</li>
- </ul>
+<p>This sample shows the selection management using built-in selection
functionality.</p>
+<p><b>selectionMode</b> attribute which controls selection mode has
three values:</p>
+<p>
+<ul>
+<li>multi</li>
+<li>single</li>
+<li>none</li>
+</ul>
+</p>
+<p>And in order to manage your selection - use <b>selection</b>
attribute which should be pointed to
+some <b>collection of objects</b>. It will <b>hold rowKeys</b> of
currently selected rows.</p>
+<p>Look to next simple sample:</p>
<ui:include src="#{demoNavigator.sampleIncludeURI}" />
<ui:include src="/templates/includes/source-view.xhtml">
<ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
@@ -19,8 +24,12 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
- <p>In order to turn on Ajax loading - just specify clientRows
- attribute with number of rows to be loaded on the client</p>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
value="/WEB-INF/src/org/richfaces/demo/tables/ExtTableSelectionBean.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View ExtSelectionBean Source"
/>
+ <ui:param name="hideLabel" value="Hide ExtSelectionBean Source"
/>
+ </ui:include>
</ui:composition>
</html>
\ No newline at end of file
Copied:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelection-sample.xhtml
(from rev 18704,
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelectionSample.xhtml)
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelection-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelection-sample.xhtml 2010-08-17
14:57:20 UTC (rev 18710)
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
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:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+ <h:panelGrid columns="2">
+ <h:form>
+ <rich:extendedDataTable
+ value="#{extTableSelectionBean.inventoryItems}" var="car"
+ selection="#{extTableSelectionBean.selection}" id="table"
+ frozenColumns="2" style="height:300px; width:500px;">
+ <a4j:ajax execute="@form"
+ event="selectionchange"
+ listener="#{extTableSelectionBean.selectionListener}"
render=":res" />
+ <f:facet name="header">
+ <h:outputText value="Cars marketplace" />
+ </f:facet>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="vendor" />
+ </f:facet>
+ <h:outputText value="#{car.vendor}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Model" />
+ </f:facet>
+ <h:outputText value="#{car.model}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Price" />
+ </f:facet>
+ <h:outputText value="#{car.price}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Mileage" />
+ </f:facet>
+ <h:outputText value="#{car.mileage}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="VIN Code" />
+ </f:facet>
+ <h:outputText value="#{car.vin}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Items stock" />
+ </f:facet>
+ <h:outputText value="#{car.stock}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Days Live" />
+ </f:facet>
+ <h:outputText value="#{car.daysLive}" />
+ </rich:column>
+ </rich:extendedDataTable>
+ </h:form>
+ <a4j:outputPanel id="res">
+ <rich:panel header="Selected Rows:"
+ rendered="#{not empty extTableSelectionBean.selectionItems}">
+ <rich:list type="unordered"
+ value="#{extTableSelectionBean.selectionItems}" var="sel">
+ <h:outputText value="#{sel.vendor} - #{sel.model} - #{sel.price}"
/>
+ </rich:list>
+ </rich:panel>
+ </a4j:outputPanel>
+ </h:panelGrid>
+</ui:composition>
\ No newline at end of file
Deleted:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelectionSample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelectionSample.xhtml 2010-08-17
13:41:49 UTC (rev 18709)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/exTableSelectionSample.xhtml 2010-08-17
14:57:20 UTC (rev 18710)
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<ui:composition
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:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich">
- <h:form>
- <rich:extendedDataTable value="#{carsBean.allInventoryItems}"
- var="car" id="table" frozenColumns="2"
- style="height:300px; width:500px;">
- <f:facet name="header">
- <h:outputText value="Cars marketplace" />
- </f:facet>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="vendor" />
- </f:facet>
- <h:outputText value="#{car.vendor}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Model" />
- </f:facet>
- <h:outputText value="#{car.model}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Price" />
- </f:facet>
- <h:outputText value="#{car.price}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Mileage" />
- </f:facet>
- <h:outputText value="#{car.mileage}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="VIN Code" />
- </f:facet>
- <h:outputText value="#{car.vin}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Items stock" />
- </f:facet>
- <h:outputText value="#{car.stock}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Days Live" />
- </f:facet>
- <h:outputText value="#{car.daysLive}" />
- </rich:column>
- </rich:extendedDataTable>
- </h:form>
-</ui:composition>
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/simpleTable-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/simpleTable-sample.xhtml 2010-08-17
13:41:49 UTC (rev 18709)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/extendedDataTable/samples/simpleTable-sample.xhtml 2010-08-17
14:57:20 UTC (rev 18710)
@@ -8,7 +8,7 @@
<h:form>
<rich:extendedDataTable value="#{carsBean.allInventoryItems}"
var="car" id="table" frozenColumns="2"
- style="height:300px; width:500px;">
+ style="height:300px; width:500px;" selectionMode="none">
<f:facet name="header">
<h:outputText value="Cars marketplace" />
</f:facet>