Creating your own Option Select Values plugin

To create your own, Option select values must create a new class that implements OptionSelectValues interface:

package com.openkm.plugin.form;

import java.util.List;
import net.xeoh.plugins.base.Plugin;
import com.openkm.bean.form.Option;

public interface OptionSelectValues extends Plugin {
    public abstract String getName();
    public abstract List<Option> getOptions() throws OptionSelectException;
}

More information at: Register a new plugin.

The new class must be loaded into the package com.openkm.plugin.form because application plugin system will try to load from there.

Do not miss the tag @PluginImplementation otherwise the application plugin system will not be able to retrieve the new class.

Methods description

MethodTypeDescription

getName()

String

Return the name what will be shown at plugins table.

getOptions()

List<Option>

Return a list with the options.

Example of the Option select values implementation

package com.openkm.plugin.form;

import java.util.ArrayList;
import java.util.List;

import com.openkm.api.OKMAuth;
import com.openkm.bean.form.Option;
import com.openkm.principal.PrincipalAdapterException;

import net.xeoh.plugins.base.annotations.PluginImplementation;

@PluginImplementation
public class OptionSelectUserList implements OptionSelectValues {
    @Override
    public String getName() {
        return "User list";
    }

    @Override
    public List<Option> getOptions() throws OptionSelectException {
        List<Option> options = new ArrayList<Option>();
try { List<String> userList; userList = OKMAuth.getInstance().getUsers(null); for (String user : userList) { Option option = new Option(); option.setLabel(OKMAuth.getInstance().getName(null, user)); option.setValue(user); options.add(option); } } catch (PrincipalAdapterException e) { throw new OptionSelectException(e); }
return options; } }