table row selection

Hi Team,

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.

please let me know procedure for this.

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		
2 Likes

Hi Eric,

Thanks for quick replay.

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.

Thanks in Advance.

Hi Naresh,

  1. Please find attached short document with screenshots to know how to create table content provider.
  2. Yes, you need to write this in the action method and need to bind this action to an async/sync command (button, icon etc…)
  3. 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.

Creating Updatable Table Content Provider.docx (126 KB)

1 Like

Hi Prasad Pokala,

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.

thanks in Advance.
Action-code.docx (13.4 KB)

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

Hi Prasad Pokala,

i tried to loop over as given in below code.

String rowvalue=“”;
for(int i=0;i<selectedRowObjects.size();i++)
{
String currRowValue=(String )selectedRowObjects.get(i);
rowvalue=currRowValue[i];

	    	getResubmitProcessStep().getParameters().getResubmitProcessStep().getResubmitProcessStep().setStepErrorsFrmProcess(rowvalue);
	    }

but still getting error as attached earlier.

i am using wm-9.9 version.

can you please provide some sample code for this mapping. that will be very helpfull for me.

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.

Hi Prasad,

i am facing below issues when i am working on your solution :frowning:
selectedStepIdsFromTable[i] = (()selectedRowObjects.get(i)).getStepId();
}

From above line my coloumn names are not populating after get(i) method.

And when i am logging selectedRowObjects.size()[b] it returning properly with selected rows count.

But when i am trying to log ‘selectedStepIdsFromTable[i]’ it returning NULL.

Share me your CAF application project pls

please find attached …
tableSelect.zip (159 KB)

Your project is corrupted. I do not see any “stepErrorsFrmProcess” under “retriveFailedTransactionsResponse”.
Capture.PNG

Hi Prasad Pokala,

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 :).

BulkResubmit.zip (222 KB)

Sure. Will get back to you soon