Using a multi-select table in RichFaces and WebFlow



The idea was to construct a multi-select table with a selectbox for each row. At the same time it had to be possible to select just one row to search for the record and display it on a different detail page.

In RichFaces version 3.3.0 GA and later versions, we have a working object called org.springframework.faces.model.ManySelectionTrackingListDataModel. Inside WebFlow we declare for instance a resultlist of some service to the multiselect object like

<evaluate expression="exampleService.getResultList()" result="viewScope.exampleList" result-type="org.springframework.faces.model.ManySelectionTrackingListDataModel"/>

In the xhtml page we can construct a multiselect table in RichFaces inside a form like

<rich:dataTable id="exampleTable" value="#{exampleList}" var="exampleRow" rowKeyVar="rowKey"
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
width = "80%"
height = "100"
rowClasses="cur"
cellpadding="0" cellspacing="0" border="0" rendered="#{exampleList.rowCount > 0}">
<f:facet name="caption"><h:outputText value="Results for this Multiselect table" /></f:facet>
<rich:column sortBy="#{exampleRow.someValue}">
<f:facet name="header">Some value</f:facet>
</rich:column>
<rich:column>
<f:facet name="header">Multi Select</f:facet>
<h:selectBooleanCheckbox id="objectSelection" name="objectSelection" value="#{exampleList.currentRowSelected}" />
</rich:column>
<rich:column>
<f:facet name="header">Action</f:facet>
<sf:commandLink id="editRecord" action="editRecord" value="Edit">
<f:param name="exampleRowIndex" value="#{exampleList.rowIndex}"/>
</sf:commandLink>

</rich:column>
</rich:dataTable>

Inside the table we have multiselect boxes that calls the currentRowSelected() method each time the user selects a row with the help of a selectBooleanCheckbox. Also inside the commandLink tag I defined a “exampleRowIndex” parameter, where the row number is filled. The row number is defined inside the RowKeyVar attribute inside the dataTable tag.

We can use all this inside WebFlow the following way. For getting all selected rows in one selection list we do
<transition on="doMultiSelections">
<evaluate expression="exampleService.setSelectedList(exampleList.selections)" />
</transition>


For selecting one row from out the request parameter we do
<transition on="editRecord" to="...">
<set name="viewScope.exampleRowIndex" value="requestParameters.exampleRowIndex" type="int"/>
*** more code ***
</transition>

with the help of the WebFlow predefined requestParameters.exampleRowIndex.

Comments are closed.

Algemeen (9)
GlassFish (49)
Java (58)
Managed Services (10)
Oracle (120)
Private Cloud Hosting (2)
SOA/BPEL/ESB (11)
Software development (92)
Strategie (7)
WSO2 (2)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

  • 071 - 82 000 82
  • Rijndijk 137 | 2394 AG Hazerswoude-Rijndijk
Oracle SOA specialized partner
Java
GlassFish
WSO2
DEMO
i-bridge
Rabobank
Greencat
Jan de Rijk
Reuma Revalidatie Rotterdam
Robeco
VU Medisch Centrum
CHS
LUMC
TomTom
TKP
NCCW
Erasmus MC
UMCG
VIR
ANWB
BVA Auctions
D-Reizen
STEDIN