voyent
How to programmatically unselect a row?  XML
Forum Index -> Components
Author Message
higgledy

Joined: 21/Apr/2009 00:00:00
Messages: 47
Offline


In the RowSelectorEvent demo, http://component-showcase.icefaces.org/component-showcase/showcase.iface

I have the demo working, and it is just what I want.

But, is there some way to unselect a row from the backing bean (using code)?

Thank you.

higgledy
davidfg

Joined: 04/Feb/2009 00:00:00
Messages: 161
Offline



Not sure, but I think the value property of rowSelector can serve you. In your class add a Boolean and set to this property.
cyberoblivion

Joined: 21/Jan/2009 00:00:00
Messages: 42
Offline


What I normally do is use a generic wrapper class

like:

Code:
public class RowSelectionWrapper<T extends Object> {
 
     private T value;
     private boolean selected;
 
     public RowSelectionWrapper() {
     }
 
     public RowSelectionWrapper(T o) {
         this.value = o;
     }
 
 
     public boolean isSelected() {
         return selected;
     }
 
     public void setSelected(boolean selected) {
         this.selected = selected;
     }
 
     public T getValue() {
         return value;
     }
 
     public void setValue(T value) {
         this.value = value;
     }
 
     public static <U> ArrayList<RowSelectionWrapper<U>> wrapList(List<U> objectList) {
         if (objectList == null) {
             return null;
         }
         ArrayList<RowSelectionWrapper<U>> wrappedList = new ArrayList<RowSelectionWrapper<U>>();
 
         for (U o : objectList) {
             RowSelectionWrapper wrapped = new RowSelectionWrapper<U>(o);
             wrappedList.add(wrapped);
         }
         return wrappedList;
     }
 }



then in my baking been declare list like:

Code:
private ArrayList<RowSelectionWrapper<MyObjectToSelect>> 
 myObjectsToSelect = new ArrayList<RowSelectionWrapper<MyObjectToSelect>>();


in the datatable use something like:

Code:
<ice:dataTable 
                      var="myObject"
                       value="#{controller.myObjectsToSelect}"
                       rows="15"
                       >
                     <ice:rowSelector id="selected"
                                  value="#{myObject.selected}"
                                 />
                         <ice:column>
                             <f:facet name="header">
                                 <ice:outputText id="column2"
                                                 value="myval"/>
                             </f:facet>
                             <ice:outputText id="CheckoutTime"
                                             value="#{myObject.value.myObjectField1}">
                              
                             </ice:outputText>
                         </ice:column>


you can use the wrapper to enable any class to support selection. from the backing bean just setSelected(false) on any items in the array you want to de-select.

emaranu

Joined: 03/Oct/2016 06:55:10
Messages: 3
Offline


In icefaces 3.3 you can bind the statemap attribute to an object in the backing bean. Then in the backing you can unselect and select the rows.

Backing bean statemap
Code:
private Map<Object, RowState> stateMap;



Unselect all selected rows. This will then update the frontend
Code:
for (Object rowData : stateMap.getSelected()) {
                        RowState s = stateMap.get(rowData);
                        s.setSelected(false);
                  }
 


Select all selectable rows. This will then update the frontend
Code:
for (Object rowData : stateMap.getSelectable()) {
                      RowState s = stateMap.get(rowData);
                      s.setSelected(true);
                 }

 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team