Author: ilya_shaikovsky
Date: 2009-07-30 12:03:53 -0400 (Thu, 30 Jul 2009)
New Revision: 15067
Modified:
branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java
branches/community/3.3.X/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-7361
Modified:
branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java 2009-07-30
13:59:53 UTC (rev 15066)
+++
branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java 2009-07-30
16:03:53 UTC (rev 15067)
@@ -4,11 +4,15 @@
package org.richfaces.demo.extendedDataTable;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.richfaces.demo.capitals.Capital;
+import org.richfaces.demo.datafilterslider.DemoInventoryItem;
import org.richfaces.model.DataProvider;
import org.richfaces.model.ExtendedTableDataModel;
+import org.richfaces.model.selection.Selection;
+import org.richfaces.model.selection.SimpleSelection;
/**
* @author Ilya Shaikovsky
@@ -18,8 +22,10 @@
private String sortMode="single";
private String selectionMode="multi";
private Object tableState;
+ private Selection selection = new SimpleSelection();
+ private List<Capital> capitals = new ArrayList<Capital>();
private ExtendedTableDataModel<Capital> dataModel;
- private List<Capital> capitals = new ArrayList<Capital>();
+ private List<Capital> selectedCapitals = new ArrayList<Capital>();
public String getSortMode() {
return sortMode;
@@ -40,6 +46,15 @@
public ExtendedTableBean() {
}
+ public void takeSelection(){
+ selectedCapitals.clear();
+ Iterator<Object> iterator = getSelection().getKeys();
+ while (iterator.hasNext()) {
+ Object key = iterator.next();
+ selectedCapitals.add(getCapitalsDataModel().getObjectByKey(key));
+ }
+ }
+
public ExtendedTableDataModel<Capital> getCapitalsDataModel() {
if (dataModel == null) {
dataModel = new ExtendedTableDataModel<Capital>(new
DataProvider<Capital>(){
@@ -84,4 +99,20 @@
this.tableState = tableState;
}
+ public Selection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(Selection selection) {
+ this.selection = selection;
+ }
+
+ public List<Capital> getSelectedCapitals() {
+ return selectedCapitals;
+ }
+
+ public void setSelectedCapitals(List<Capital> selectedCapitals) {
+ this.selectedCapitals = selectedCapitals;
+ }
+
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml 2009-07-30
13:59:53 UTC (rev 15066)
+++
branches/community/3.3.X/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml 2009-07-30
16:03:53 UTC (rev 15067)
@@ -1,64 +1,97 @@
<!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">
+
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>
- <h:form>
- <h:panelGrid columns="2" columnClasses="top,top">
- <rich:extendedDataTable value="#{extendedTableBean.capitalsDataModel}"
var="cap" id="table"
- width="580px" height="400px"
sortMode="#{extendedTableBean.sortMode}"
- selectionMode="#{extendedTableBean.selectionMode}"
tableState="#{extendedTableBean.tableState}">
- <rich:column sortable="false" label="Flag">
- <f:facet name="header">
- <h:outputText value="Flag"/>
- </f:facet>
- <h:graphicImage value="#{cap.stateFlag}"/>
- </rich:column>
- <rich:column sortable="true" sortBy="#{cap.state}"
filterBy="#{cap.state}" filterEvent="onkeyup" width="170px"
label="State Name">
- <f:facet name="header">
- <h:outputText value="State Name"/>
- </f:facet>
- <h:outputText value="#{cap.state}"/>
- </rich:column>
- <rich:column sortable="true" sortBy="#{cap.name}"
filterBy="#{cap.name}" filterEvent="onkeyup" width="170px"
label="State Capital">
- <f:facet name="header">
- <h:outputText value="State Capital"/>
- </f:facet>
- <h:outputText value="#{cap.name}"/>
- </rich:column>
- <rich:column sortable="false" label="Time Zone">
- <f:facet name="header">
- <h:outputText value="Time Zone"/>
- </f:facet>
- <h:outputText value="#{cap.timeZone}"/>
- </rich:column>
- </rich:extendedDataTable>
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Sort/Selection modes changing"/>
- </f:facet>
- <h:panelGrid columns="2">
- <h:outputText value="Sort Mode:"/>
- <h:selectOneMenu value="#{extendedTableBean.sortMode}">
- <f:selectItem itemLabel="Single" itemValue="single"/>
- <f:selectItem itemLabel="Multi" itemValue="multi"/>
- <a4j:support event="onchange" ajaxSingle="true"
reRender="table"/>
- </h:selectOneMenu>
- <h:outputText value="Selection Mode:"/>
- <h:selectOneMenu value="#{extendedTableBean.selectionMode}">
- <a4j:support ajaxSingle="true" event="onchange"
reRender="table"/>
- <f:selectItem itemLabel="Single" itemValue="single"/>
- <f:selectItem itemLabel="Multi" itemValue="multi"/>
- <f:selectItem itemLabel="None" itemValue="none"/>
- </h:selectOneMenu>
- </h:panelGrid>
- </rich:panel>
+<ui:composition>
+ <h:form>
+ <h:panelGrid columns="2" columnClasses="top , top">
+ <rich:extendedDataTable
+ value="#{extendedTableBean.capitalsDataModel}" var="cap"
id="table"
+ width="580px" height="400px"
+ sortMode="#{extendedTableBean.sortMode}"
+ selectionMode="#{extendedTableBean.selectionMode}"
+ tableState="#{extendedTableBean.tableState}"
+ selection="#{extendedTableBean.selection}">
+ <rich:column sortable="false" label="Flag">
+ <f:facet name="header">
+ <h:outputText value="Flag" />
+ </f:facet>
+ <h:graphicImage value="#{cap.stateFlag}" />
+ </rich:column>
+ <rich:column sortable="true" sortBy="#{cap.state}"
+ filterBy="#{cap.state}" filterEvent="onkeyup"
width="170px"
+ label="State Name">
+ <f:facet name="header">
+ <h:outputText value="State Name" />
+ </f:facet>
+ <h:outputText value="#{cap.state}" />
+ </rich:column>
+ <rich:column sortable="true" sortBy="#{cap.name}"
+ filterBy="#{cap.name}" filterEvent="onkeyup"
width="170px"
+ label="State Capital">
+ <f:facet name="header">
+ <h:outputText value="State Capital" />
+ </f:facet>
+ <h:outputText value="#{cap.name}" />
+ </rich:column>
+ <rich:column sortable="false" label="Time Zone">
+ <f:facet name="header">
+ <h:outputText value="Time Zone" />
+ </f:facet>
+ <h:outputText value="#{cap.timeZone}" />
+ </rich:column>
+ <a4j:support reRender="selectiontable"
+ action="#{extendedTableBean.takeSelection}"
+ event="onselectionchange" />
+ </rich:extendedDataTable>
+ <h:panelGroup layout="block" style="width:250px">
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="Sort/Selection modes changing" />
+ </f:facet>
+ <h:panelGrid columns="2">
+ <h:outputText value="Sort Mode:" />
+ <h:selectOneMenu value="#{extendedTableBean.sortMode}">
+ <f:selectItem itemLabel="Single" itemValue="single" />
+ <f:selectItem itemLabel="Multi" itemValue="multi" />
+ <a4j:support event="onchange" ajaxSingle="true"
reRender="table" />
+ </h:selectOneMenu>
+ <h:outputText value="Selection Mode:" />
+ <h:selectOneMenu value="#{extendedTableBean.selectionMode}">
+ <a4j:support ajaxSingle="true" event="onchange"
reRender="table" />
+ <f:selectItem itemLabel="Single" itemValue="single" />
+ <f:selectItem itemLabel="Multi" itemValue="multi" />
+ <f:selectItem itemLabel="None" itemValue="none" />
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </rich:panel>
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="Currently selected rows:" />
+ </f:facet>
+ <rich:dataTable value="#{extendedTableBean.selectedCapitals}"
+ var="sel" id="selectiontable">
+ <rich:column>
+ <h:graphicImage value="#{sel.stateFlag}" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{sel.state}" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{sel.name}" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{sel.timeZone}" />
+ </rich:column>
+ </rich:dataTable>
+ </rich:panel>
+ </h:panelGroup>
</h:panelGrid>
- </h:form>
- </ui:composition>
+ </h:form>
+</ui:composition>
</html>
\ No newline at end of file