Creating your own Default Form Values

You can create your own Default form Values.


  • The new Default Form Values class must implement the "FormDefaultValues" interface.
  • The new Default Form Values class must be declared under the package "com.openkm.plugin.form.values".
  • The new Default Form Values class must be annotated with "@PluginImplementation".
  • The new Default Form Values class must extend of "BasePlugin".

Default Form Values interface:

package com.openkm.plugin.form.values;

import com.openkm.bean.form.FormElement;
import net.xeoh.plugins.base.Plugin;

import java.util.List;

public interface FormDefaultValues extends Plugin {

    String getName();

    void setDefaultValues(String grpName, List<FormElement> formElementList);

The new class must be loaded into the package com.openkm.plugin.form.values because the application plugins system will try to load it from there. See the sample below:

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

More information at: Register a new plugin.

Method description


setDefaultValues(String grpName, List<FormElement> formElementList)


The method sets defaults values for the form elements of the group.

Example of the default form values implementation

package com.openkm.plugin.form.values;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.openkm.bean.form.FormElement;
import com.openkm.bean.form.Input;
import com.openkm.plugin.BasePlugin;

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

 * Implementation of default form values
public class FormDefaultValuesDate extends BasePlugin implements FormDefaultValues {

    public String getName() {
        return "Date Default Values";

    public void setDefaultValues(String grpName, List<FormElement> formElementList) {
        if (grpName.equalsIgnoreCase("okg:test")) {
            for (FormElement element : formElementList) {
                if (element.getName().equals("")) {
                    Input input = (Input) element;
                    if (input.getValue().isEmpty()) {
                        DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
                        Date date = new Date();


Metadata definition

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.8//EN" "">
   <property-group label="Test" name="okg:test" defaultValueClassName="com.openkm.plugin.form.values.FormDefaultValuesDate">
      <input label="Fecha" type="date" name=""/>