I am new to CAF. I am working on a task, where i need to display some result in Table format. And this result have multiple columns. till this i am able to display. here to this table i need to add ‘CheckBox’ and need to select some columns and this columns data need to passed to another WS as input.
You can do the row selection by adding a “Select Row Checkbox” control to one of the columns of your table control.
Then in your server side action handler for some command control you can get the row objects backing the selected rows with something like this:
//TODO: get a reference to the table provider
ISelectableTableContentProvider tableProvider = getTableRowProvider();
List<Object> selectedRowObjects = new ArrayList<Object>();
Collection<String> rowSelectedIds = tableProvider.getRowSelectedIds();
String originalRowId = tableProvider.getRowId();
try {
//loop to position the table provider on each
// selected row
for (String rowId : rowSelectedIds) {
tableProvider.setRowById(rowId);
Object currentRow = tableProvider.getCurrentRow();
selectedRowObjects.add(currentRow);
}
} finally {
//put it back
tableProvider.setRowById(originalRowId);
}
//TODO: do something with your selectedRowObjects list here
When i am trying to place ‘select row checkbox’ , i am getting error as given in attached screen shot.
And can u please elaborate more how to use Java code which you given(I am guessing i need to write this is action place and need to map this action to submit button). please correct if i am wrong. And also please let me know how to map this data to next WS input.
Please find attached short document with screenshots to know how to create table content provider.
Yes, you need to write this in the action method and need to bind this action to an async/sync command (button, icon etc…)
While you have the details of selected row with you (from the code Eric provided), you can access the parameters of webservice connector by calling “getParameters()” method from its Managed Bean and then calling the setter methods inside it will help you to set the inputs of webservice.
thank you for clear explanation. I am unable to select columns now.
But when i am planning to Map this service Output( selectedRowObjects ) to my next WS input , i am getting error as given in attachment.
i am attaching entire action code also here. please check and correct me if anything wrong.
Naresh, you are trying to set whole List as input to your webservice connector. List will have your entire selected rows. You have to iterate on this list and then collect the values you want out of those rows and then pass in to webservice connector
First of all, you should know what is the input type that your webservice connector accepts. Otherwise you will keep getting the cast exceptions.
Assuming that your “setStepErrorsFrmProcess” accepts a string array of stepIds, below is the sample code:
String selectedStepIdsFromTable = new String[selectedRowObjects.size()];
// Iterate through selected rows and get the STEP ID (or any other value you are interested in)
for(int i=0;i<selectedRowObjects.size();i++)
{
selectedStepIdsFromTable[i] = ((<TYPE CAST TO ITS CLASS>)selectedRowObjects.get(i)).getStepId();
}
// Invoke your webservice
getResubmitProcessStep().getParameters().getResubmitProcessStep().getResubmitProcessStep().setStepErrorsFrmProcess(selectedStepIdsFromTable);
Above code is assuming your “setStepErrorsFrmProcess” accepts string as input. If it accepts some other type then you need to prepare your inputs according and then pass into it.
Sorry for delayed response. i am busy with another activity. here i am attaching new .zip file related to my project.
in CAF screen i added two buttons with different actions.
On ‘another’ button i used logic which you given above. Still facing same issue :(.
On ‘Resubmit’ button i used another logic using ‘List selected = stepErrorsFrmProcessProvider.getSelectedRows();’ method. here also i am facing unknown issue. Please check and help me on this if you get free time :).