Params Select field

AttributeDescriptionRequired

label

The text shown as label in user interface.

true

name

Unique field identifier.

Two fields can't have the same name in the same task definion. Name must be unique.

true

type

Type value. Allowed types:

  • simple ( single choice allowed ).
  • multiple ( multiple choice allowed ).
true

table

Metadata table name.

Application can store values into metadata table, that can be used in this query.

*

width

The width of the HTML element. false

height

The height of the HTML element. false

optionsQuery

A metadata query or SQL query used to get the select options. *

Child elements:

  • Option. Couples of XML <option label="label text" value="unique identifier value"/> values or <option label="label text" value="unique identifier value" parentValue="parent unique identifier value"/> in case is set some hierarchical relationship.
  • Validator. For more information see Params Validator element.

* There're two options to get option values:

  • Directly defined in XML.
  • Metadata table ( table + optionsQuery ).

One of these options must be defined, otherwise you will get an error. A combination of several of these cannot be done , only one can be choosen.

Basic select example

  • Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.1//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.1.dtd">
<report-parameters>
  <select label="select label" name="select" type="simple">
    <option label="one" value="001" />
    <option label="two" value="002" />
    <option label="three" value="003" />
  </select>
</report-parameters>

Allow multiple choice

  • Type is equal to multiple.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.1//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.1.dtd">
<report-parameters>
  <select label="select label" name="select" type="multiple">
    <option label="one" value="001" />
    <option label="two" value="002" />
    <option label="three" value="003" />
  </select>
</report-parameters>

Hierarchical relationship

  • The field option values of "childrenSelect" have parent relation with "parentSelect". It's defined by parentElement="parentSelect".
  • The option value "benefits" of field "childrenSelect" has a parent value "directives" from field "parentSelect".

Tree relationships:

  • directives
    • benefits
    • eligibility
    • services
  • handbook
    • basic
    • normal
    • advanced
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.1//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.1.dtd">
<report-parameters>
  <select label="Parent" name="parentSelect" type="simple">
    <option value="directives" label="Directives" />
    <option value="handbook" label="Handbook Paragraphs" />
  </select> 
  <select label="Children" name="childrenSelect" type="simple" parentElement="parentSelect">
    <option value="benefits" label="Benefits" parentValue="directives" />
    <option value="elegibility" label="Eligibility" parentValue="directives" />
    <option value="services" label="Services" parentValue="directives" />
    <option value="basic" label="Basic" parentValue="handbook" />
    <option value="normal" label="Advanced" parentValue="handbook" />
    <option value="advanced" label="Normal" parentValue="handbook" />
  </select>
</report-parameters>

Options based on metadata table

  • Application use two tables named OKM_DB_METADATA_TYPE AND OKM_DB_METADATA_VALUE that helps on storing options values used in selects. That's very useful when you got a large number of values.
  • In table OKM_DB_METADATA_TYPE are stored metadata table definition ( table name, column name and column type ).
  • In table OKM_DB_METADATA_VALUE are stored record values.

Create metadata table definition.

The table will be called country, with two columns, country_id and country_name.

The country_id column is integer type and country_name is text type.

The country_id is set as column 0 with col00 value.

The country_name is set as column 1 with col01 value.

  • Go to Administration > Utilities > Database query.
  • At bottom right select JDBC from list.
  • Paste the SQL in the box
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='country';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('country', 'col00', 'integer', 'country_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('country', 'col01', 'text', 'country_name');
  • Click at bottom right the Execute button.

Insert metadata table values:

  • Go to Administration > Utilities > Database query.
  • At bottom right select JDBC from list.
  • Paste the SQL in the box
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMV_TABLE='country';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('country', '001', 'Australia');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('country', '002', 'Canada');
  • Click at bottom right the Execute button.

Depending on your database the insert queries can not be matched, for example in Oracle:

INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.NEXTVAL, 'country', 'col00', 'integer', 'country_id');

More information at Creating your own database tables.

Finally the XML definition:

  • In optionsQuery the values that begins with character $ are identified as column names. See $country_id and $country_name below.
  • Can use normal sql clausules like "order by" etc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.1//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.1.dtd">
<report-parameters>
  <select label="country" name="country" type="simple" table="country" 
          optionsQuery="select $country_id, $country_name from DatabaseMetadataValue dmv where dmv.table='country' order by $country_name" />
</report-parameters>

Based on SQL query

We can also get these option values using an SQL query. This SQL sentence should be put on the optionsQuery attribute, but the table attribute should be empty (otherwise this query is used as a metadata query). Note that the first element returned in every row is the option value and the second one is the option label. 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.1//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.1.dtd">
<report-parameters>
  <select label="country" name="country" type="simple"
          optionsQuery="select CT_ID, CT_NAME from COUNTRY order by CT_NAME" />
</report-parameters>

The table used in this sample is defined as:

create table COUNTRY (
    CT_ID varchar(2),
    CT_NAME varchar(32),
    primary key(CT_ID)
);

insert into COUNTRY (CT_ID, CT_NAME) values ('es', 'Spain');
insert into COUNTRY (CT_ID, CT_NAME) values ('pt', 'Portugal');
insert into COUNTRY (CT_ID, CT_NAME) values ('it', 'Italy');

Based on className

To help getting a list from external applications or other purposes, your own class can be built to retrieve the option values from those systems .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.5//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.5.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label" name="okp:consulting.select" type="simple"
            className="com.openkm.plugin.form.OptionSelectUserList" />
  </property-group>
</property-groups>

For more information read Creating your own Option Select Values plugin.

Suggested options

Based on the content analyzer the application can suggest some options values. At the user interface the suggested options will be shown in green.

The application has some implementations that can easily be extended.

  • com.openkm.form.suggestion.DocumentContentContainsSuggestion: Get suggestions based on document content (use String.contains)
  • com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Get suggestions based on document content (Use StringTokenizer).
  • com.openkm.form.suggestion.DocumentTermsSuggestion: Get suggestions based on document term vectors.

For more information read Creating your own Suggestion Analyzer.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.5//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.5.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label"  name="okp:consulting.select" type="multiple"
            suggestion="com.openkm.form.suggestion.DocumentContentContainsSuggestion">
      <option label="one" value="001" />
      <option label="two" value="002" />
      <option label="three" value="003" />
     </select>
  </property-group>
</property-groups>