how to save the selected values by using the "Select Row Checkbox"?

Hi All,

I have a problem while using the “Select Row Check box”

My scenario:

I have a table with two columns.
One column displays some list of item names and another column will displays a check box to select/unselect [Select Row Check box].

When even i selects a check box i want to append the item name(s) to an string or array list.

Can anyone help me on this.

Thanks in advance,
Guruprasd.B

If you need to respond to the selection events on the client side without a round trip to the server, you can attach a row change listener to the table control with a custom function in a script block that gets called when a row select occurs.

For example:


CAF.model("#{caf:cid('yourTableIdHere')}".addRowChangeListener(function(tableId,rowId,eventType) {
    if (eventType == "select") {
        alert('Row Selection Changed for Row: ' + rowId);
    }
});

Or if you want to get the selected rows on the server side inside of an action handler method, you can use the methods on the selectable content provider object.

See: http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_and_MWS_Java_API_Reference/com/webmethods/caf/faces/data/ISelectableTableContentProvider.html#getRowSelectedIds()

For example:


ISelectableTableContentProvider tableContentProvider = [TODO_get_your_table_content_provider_here];
Collection selectedRowIds = tableContentProvider.getRowSelectedIds();

Hi Eric Norman,

Thanks your help.

I want the selected values on click of some button [Ex: Ok]. I have used the 2nd example and it is listing all the selected values.

Once again thanks for your help.

Regards,
Guruprasad.B

Hi Norman,

I am currently using the 9.8 version and i am trying to clear the selected rows from the server side, but i could not succeeded.

Below is the code i am using to push the selected rows to the another custom ArrayList.

getPlacedOrderDetails().add((caf.war.SAGInternalSystems.wsclient.enquireecafelist.SAG_ECAFEWsEnquireECafeListStub.OrderDetails) getEnquireECafeTableProvider().getSelectedRows().

later i have used the below code to clear the selected items.

getEnquireECafeTableProvider().getSelectedRows().clear().

Unfortunately , above code throws some error as below.

UnsupportedOperationException.

Please help me out from the above error, or do we have any other way to remove the values from the selected array bean from the server side.

Thanks in advance.

The selected rows list is immutable.

If you want to clear the selected rows, you should call the setRowSelectedIds method and pass it an empty list.

for example:

getEnquireECafeTableProvider().setRowSelectedIds(Collections.emptyList());

Reference: