Bean shell retrieve data from selected rows in Datalist

Confluence User - 24 Jul, 2019

Hi,

I'm coding a Bean Shell action for a datalist

I'm trying to differentiate the action based on the value of column "Activité".

 

I understand that the Bean Shell action is fed with "rowKeys" which are the primary Keys of the selected rows. How do I get the "Activité" value of the selected rows?

Thanks a lot

Baptiste

datalists

2


29 Jul, 2019
confluenceUser
confluenceUser
29 Jul, 2019
confluenceUser
confluenceUser

Hi,

I used that solution already, but I thought there would be a more convenient way to do it.

What i did: (keys and dataList) are variables fed by the system when clicking on a Datalist Bean Shell action.

Keys are the primary keys of the selected items

datalist is the whole datalist (of selected AND unselected items)

public void completeSubculture(String[] keys, DataList dataList) {
	DataListService dataListService = (DataListService) AppUtil.getApplicationContext().getBean("dataListService");
	String sql = "";
	Connection con = null;
	DataListCollection rows = dataList.getRows();

	for (String key : keys) {
		String activityName = "";
		for (int i = 0; i < rows.size(); i++) {
			if (key.equals(dataListService.evaluateColumnValueFromRow(rows.get(i),"id"))){
				activityName = dataListService.evaluateColumnValueFromRow(rows.get(i),"activityName");
				System.out.println(activityName);
			}
		}
	}
}


What i find fastidious is that the only way of retrieving a row is by comparing primary keys.

But it works so... great!

Cheers


Baptiste

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print