Ir al contenido
Otras versiones

Cargando…

Creating your own Option Select Values plugin

Esta página aún no está disponible en tu idioma.

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;
}

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

Method Type Description
getName() String Return the name what will be shown at plugins table.
getOptions() List Return a list with the options.

Example of the Option select values implementation

Section titled “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;
}
}