• PropertyGroups - Select - multiple

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #29802  by Catscratch
 
Hi,

regarding the Wiki Page currently only simple select properties can be used.
Select
- type: Actually can be only "simple". Simple means that only one option can be selected at a time. Defaults to "simple".
I saw that openkm community 6.3 already supports multiple attributes for a select form. In the frontend you can add more than one values for a select type="multiple".
Unbenannt.PNG
Unbenannt.PNG (2.08 KiB) Viewed 3553 times
So it seems only the REST endpoint and the SDK won't support this, because there you always only got key-value pairs (e.g. for setPropertyGroupPropertiesSimple) instead of key-list<value> pairs.

So my question is, do you have some kind of roadmap about when this feature will be available?

Thanks.
 #29822  by jllort
 
To select multiple values in select must use special character separator into a single string, the separator is ;

For example if you want to set two values 1,2 then the String in setPropertiesSimple should be "1;3"

Sincerally is not documented on wiki, we will add some note in REST SDK section
 #29828  by Catscratch
 
Thanks for reply, but it is not working.

Setting only one ID is working. E.g. ID1. Or setting only ID2.
But setting "ID1;ID2" is not working. The property remains empty.

Edit: I further investigated the problem. In PropertyGroupService.java you don't care about the ";".

Linie 199:
Code: Select all
for (Option opt : sel.getOptions()) {
	if (opt.getValue().equals(value)) {
		opt.setSelected(true);
	} else {
		opt.setSelected(false);
	}
}
Edit2: I modified your code and now it is working.
Code: Select all
} else if (fe instanceof Select) {
	Select sel = (Select) fe;

	// Check if there are multiple values in the value string separated by ';'
	List<String> splitValues = Arrays.asList(value.split(";"));

	for (Option opt : sel.getOptions()) {
		if (splitValues.contains(opt.getValue())) {
			opt.setSelected(true);
		} else {
			opt.setSelected(false);
		}
	}
}
But a better way would be to refactor the REST interface for not using a Map<String, String> but a Map<String, List<String>>.

Anyway, you can use my code if it helps.
 #29839  by jllort
 
It's a bug on this community version, I've upload today a patch. Try tomorrow the nighly build (integration.openkm.com).
 #29851  by Catscratch
 
I synchronized my own code with yours and yes, your solution is working too. Thanks!

One last hint: Instead of hardcoding
Code: Select all
public static String LIST_SEPARATOR = ";";
in Config.java, you could push it to Configuration View in the admin panel.
 #29877  by jllort
 
You talk about, create new configuration property to change default separator, is that ? I do not know if it's good idea because for example windows tools I think we're using ";" by default. If you see some advantage on be able to change it, we can consider your proposal.
 #29885  by Catscratch
 
Was just an idea. A better way would be to not use a separator and use another datatype (e.g. List<String>) instead. Doing this by a separator seems to only be a workaround.
 #29902  by jllort
 
The main idea was to do it as simply as possible, like the name indicates. Properties use a map of <String, String>, to follow your purpose should be serialized the list to string value ( json or similar ), for example with json ( we thought in past, the easiest serialization type was use character separator ). Also There's other method setProperties what take advantage of FormElement classes ( there are Select classes with option list ), the formal implementation ( but not very comfortable )

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.