Product Logos BridgeIt Services Banner
rowSelector: no row selection and no selectionListener  XML
Forum Index -> Components
Author Message
nicklamort

Joined: 17/Jun/2011 12:22:06
Messages: 20
Offline


I have an ice:datatable with a rowSelector that isn't working propery. In fact, its not doing anything at all other than changing color onHover. I would like a row to change color when clicked and fire the selectionListener event. I'm using icefaces 1.8.2

jsp:

Code:
<ice:dataTable headerClass="icelist-header" id="partsTbl" rowClasses="icelist-row-even,icelist-row-odd"
         value="#{easp$PartsInv.partsTblDataModel}"  var="currentRow">
         <ice:column id="col1">
             <ice:rowSelector binding="#{easp$PartsInv.rowSel}" id="rowSel" selectedClass="selectMe" selectionListener="#{easp$PartsInv.rowClick}"
             value="#{currentRow['selected']}"></ice:rowSelector>
             <f:facet name="header">
                 <ice:outputText id="outputText1" value="Part No"/>
             </f:facet>
             <ice:outputText id="outputText2" value="#{currentRow['PartNumber']}"/>
         </ice:column>
         <ice:column id="col2">
             <f:facet name="header">
                 <ice:outputText id="outputText3" value="Description"/>
             </f:facet>
             <ice:outputText id="outputText4" value="#{currentRow['PartDescription']}"/>
         </ice:column>
         <ice:column id="col3">
             <f:facet name="header">
                 <ice:outputText id="outputText5" value="From WH"/>
             </f:facet>
             <ice:outputText id="outputText6" value="#{currentRow['FromWH']}"/>
         </ice:column>
         <ice:column id="col4">
             <f:facet name="header">
                 <ice:outputText id="outputText7" value="Date Sent"/>
             </f:facet>
             <ice:outputText id="outputText8" value="#{currentRow['DateSent']}" />
         </ice:column>
     </ice:dataTable>


backing bean:

Code:
public void rowClick(RowSelectorEvent rse)
     {
         //int i = this.partsTblDataModel.getRowIndex();
         //this.rowSel.setClickedRow(i);
         int i = rse.getRow();
         this.lblStatus.setValue(String.valueOf(i) + " row was clicked");
     }


I believe the highlighting problem has something to do with the rowSelector's value attribute. When I remove it, all rows in the table get selected when any single row is clicked. I found docs that said to set it like so; I've tried currentRow.selected and currentRow['selected'].. neither work. Any help is greatly appreciated, thanks!

ps - here is a link to the same question on SO: http://stackoverflow.com/questions/7437909/icefaces-datatable-rowselecor-selectionlistener
nicklamort

Joined: 17/Jun/2011 12:22:06
Messages: 20
Offline


I figured it out. Set the value attribute of rowselector to bind to a boolean in the backing bean: value="#{easp$PartsInv.selected}"

Have the get method of this variable return true or false if the datatable.getRowIndex() == the row the got clicked (can set this in selectionListener)
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team