Getting data from selected rows

I’m giving up on my previous post on ClassCastException because I need to get SOMETHING working. I have the output from an IS service linked to a content provider that allows use of the SelectRow objects on a table. Great. They work. But…so far I’ve been unable to extract any data from the selected rows.
I am not familiar with Java or eclipse, both of which are required to accomplish what I need to accomplish. I have gone through forums, CAF samples, tutorials…I am still not getting the information I need.

So, if I iterate through the selectedRows of my content provider…how do I get the contents of those rows???

:x

Hi,
this is a bit complex to explain in a post, but I’ll try it… I will base what I say on the sample “wm_coreproviderstest/WebContent/view/Table/Selection.view”.
I suppose you have:

  • an array of items (in the sample this is a SampleItem).
  • a content provider based on that array (Selection Provider)
  • the content provider has its property “Row Id Expression” to a unique identifier inside the row java type (in the sample, “id”). Without this property (Row Id Binding) correctly configured, it will not work
  • a table (generated via drag and drop of the content provider) or async table
  • in the table you have added a “Select Row Checkbox” or “Select Row on Click” controls.

Since you want to access, on the server side, the selected rows, you will need some action that takes the rows selected on the browser to the “server”. In the sample this is done by the “Get Selected Rows” button, bound to the “processSelection” action.
In that method, you can do something like:

List<Object> selectedRows = getSelectionProvider().getSelectedRows();
SampleItem testItem = null;
for (Object object : selectedRows) {
   testItem = (SampleItem) object;
   System.out.println("+++ item: " + testItem.getId());
}

That should make it…
hope this helps,
Javier