Author: ilya_shaikovsky
Date: 2007-11-23 12:48:57 -0500 (Fri, 23 Nov 2007)
New Revision: 4240
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/scrollableDataTable/examples/scrollableDataTable.xhtml
Log:
http://jira.jboss.com/jira/browse/RF-1422
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java 2007-11-23
17:45:21 UTC (rev 4239)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java 2007-11-23
17:48:57 UTC (rev 4240)
@@ -4,13 +4,15 @@
package org.richfaces.datatablescroller;
import java.math.BigDecimal;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.richfaces.demo.datafilterslider.DemoInventoryItem;
+import org.richfaces.model.ScrollableTableDataModel.SimpleRowKey;
+import org.richfaces.model.selection.SimpleSelection;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
@@ -18,6 +20,8 @@
*
*/
public class DataTableScrollerBean {
+ private SimpleSelection selection = new SimpleSelection();
+ private ArrayList<DemoInventoryItem> selectedCars = new
ArrayList<DemoInventoryItem>();
private static int DECIMALS = 1;
private static int ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;
@@ -137,4 +141,32 @@
b[i] = (byte)rand('A', 'Z');
return new String(b);
}
+
+ public SimpleSelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(SimpleSelection selection) {
+ System.out.println("Setting Started");
+ this.selection = selection;
+ System.out.println("Setting Complete");
+ }
+
+ public String takeSelection() {
+ getSelectedCars().clear();
+ Iterator<SimpleRowKey> iterator = getSelection().getKeys();
+ while (iterator.hasNext()){
+ SimpleRowKey key = iterator.next();
+ getSelectedCars().add(getAllCars().get(key.intValue()));
+ }
+ return null;
+ }
+
+ public ArrayList<DemoInventoryItem> getSelectedCars() {
+ return selectedCars;
+ }
+
+ public void setSelectedCars(ArrayList<DemoInventoryItem> selectedCars) {
+ this.selectedCars = selectedCars;
+ }
}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/scrollableDataTable/examples/scrollableDataTable.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/scrollableDataTable/examples/scrollableDataTable.xhtml 2007-11-23
17:45:21 UTC (rev 4239)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/scrollableDataTable/examples/scrollableDataTable.xhtml 2007-11-23
17:48:57 UTC (rev 4240)
@@ -10,7 +10,8 @@
<rich:spacer height="30" />
<rich:scrollableDataTable rowKeyVar="rkv" frozenColCount="1"
height="400px"
width="700px" id="carList" rows="40"
columnClasses="col"
- value="#{dataTableScrollerBean.allCars}" var="category"
sortMode="single">
+ value="#{dataTableScrollerBean.allCars}" var="category"
sortMode="single"
+ selection="#{dataTableScrollerBean.selection}">
<rich:column id="make">
<f:facet name="header"><h:outputText
styleClass="headerText" value="Make" /></f:facet>
@@ -39,7 +40,38 @@
- </rich:scrollableDataTable>
+ </rich:scrollableDataTable>
+
+ <a4j:commandButton value="Take Selection" reRender="table"
action="#{dataTableScrollerBean.takeSelection}"
oncomplete="javascript:Richfaces.showModalPanel('panel');"/>
</h:form>
-
+ <rich:modalPanel id="panel" autosized="true">
+ <f:facet name="header">
+ <h:outputText value="Selected Rows"/>
+ </f:facet>
+ <f:facet name="controls">
+ <a href="#"
onclick="javascript:Richfaces.hideModalPanel('panel')">X</a>
+ </f:facet>
+ <rich:dataTable value="#{dataTableScrollerBean.selectedCars}"
var="sel" id="table">
+ <rich:column>
+ <f:facet name="header"><h:outputText value="Make"
/></f:facet>
+ <h:outputText value="#{sel.make}" />
+ </rich:column>
+ <rich:column id="model">
+ <f:facet name="header"><h:outputText value="Model"
/></f:facet>
+ <h:outputText value="#{sel.model}" />
+ </rich:column>
+ <rich:column id="price">
+ <f:facet name="header"><h:outputText value="Price"
/></f:facet>
+ <h:outputText value="#{sel.price}" />
+ </rich:column>
+ <rich:column id="mileage">
+ <f:facet name="header"><h:outputText value="Mileage"
/></f:facet>
+ <h:outputText value="#{sel.mileage}" />
+ </rich:column>
+ <rich:column id="stock">
+ <f:facet name="header"><h:outputText value="Stock"
/></f:facet>
+ <h:outputText value="#{sel.stock}" />
+ </rich:column>
+ </rich:dataTable>
+ </rich:modalPanel>
</ui:composition>
\ No newline at end of file