Difference between revisions of "Form Element description"

From OpenKM Documentation
Jump to: navigation, search
(Example)
(Example)
Line 123: Line 123:
 
</source>
 
</source>
  
Property group xml definition
+
Property Group xml definition. If the document content where the Property Group is assigned match a "provincia", then is offered as suggestion:
 +
 
 
<source lang="xml">
 
<source lang="xml">
 
  <select label="Provincia" name="okp:provincia" type="simple"  
 
  <select label="Provincia" name="okp:provincia" type="simple"  

Revision as of 09:07, 28 May 2013

Input

Used to enter free form text:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.
  • type: This value constrain value type. Allowed types: text, date, link or folder.
  • value: Here you can specify a default value for this component.
  • width: The width of the component. Defaults to browser default HTML input width.
  • height: The height of the component. Defaults to browser default HTML input height.

Suggestbox

This is an implementation of the typical AJAX suggest box component:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.
  • table: The table where the data is stored.
  • filterQuery: An Hibernate query to filter the data. Use {0} to place the user input. Required.
  • valueQuery: An Hibernate query to obtain the value of a identifier. Use {0} to place the identifier. Required.
  • dialogTitle: The text which describes the title of the dialog. Required.
  • filterMinLen: The minimum chars in input to begin to filter results.

Example

Create database metadata definition

-- NORMAL
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('provincia', 'col00', 'integer', 'pro_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('provincia', 'col01', 'text', 'pro_nombre');

-- SOME DATABASES NEED SET DMT_ID, LIKE ORACLE 
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', 'col00', 'integer', 'pro_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', 'col01', 'text', 'pro_nombre');

Create database metadata values

-- NORMAL
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMV_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('provincia', '1', 'Araba');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('provincia', '2', 'Albacete');

-- SOME DATABASES NEED SET DMV_ID, LIKE ORACLE
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMT_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_ID, DMV_TABLE, DMV_COL00, DMV_COL01) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', '1', 'Araba');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_ID, DMV_TABLE, DMV_COL00, DMV_COL01) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', '2', 'Albacete');

Property group xml definition

<suggestbox label="Provincia" name="okp:provincia" width="200px"
   table="provincia" dialogTitle="Seleccionar Provincia" filterMinLen="3"
   filterQuery="select $pro_id, $pro_nombre from DatabaseMetadataValue dmv where dmv.table='provincia' and lower(dmv.$pro_nombre) like '%{0}%' order by dmv.$pro_nombre"
   valueQuery="select $pro_id, $pro_nombre from DatabaseMetadataValue dmv where dmv.table='provincia' and dmv.$pro_id='{0}'" />

Checkbox

Best used to represent boolean data:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.

TextArea

Similar to Input but for bigger text:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.
  • value: Here you can specify a default value for this component.
  • width: The width of the component. Defaults to 300px.
  • height: The height of the component. Defaults to 100px.

Select

In this case, the value can be selected from a list of predefined one. Every select component can contain an arbitrary number of options bigger than one.

  • label: The text which describes the component. Required.
  • name: This value is used to access the value selected by the user. Required.
  • type: Actually can be only "simple". Simple means that only one option can be selected at a time. Defaults to "simple".
  • width: The width of the component. Defaults to browser default HTML select width.
  • height: The height of the component. Defaults to browser default HTML select height.

Since OpenKM 6.1 you have a couple of new properties to get the select option values from a database query. Lets see a sample use of these new values:

  • table: The metadata table used in this query.
  • optionsQuery: A metadata query used to obtain the select options.

These options were include in Workflow Forms since OpenKM Professional 6.2.10 and OpenKM Community 6.2.3, and defined in workflow-forms-2.4.dtd.

Since OpenKM 6.2.17 Professional there is a new property called suggestion. This can be set to a class which implements a way of getting Option suggestions. By default OpenKM provides a couple of implementations:

  • 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.

These options was include in Property Group, and defined in property-groups-2.2.dtd.

Example

Create database metadata definition

-- NORMAL
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('provincia', 'col00', 'integer', 'pro_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('provincia', 'col01', 'text', 'pro_nombre');

-- SOME DATABASES NEED SET DMT_ID, LIKE ORACLE
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', 'col00', 'integer', 'pro_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', 'col01', 'text', 'pro_nombre');

Create database metadata values

-- NORMAL
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMV_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('provincia', '1', 'Araba');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('provincia', '2', 'Albacete');

-- SOME DATABASES NEED SET DMV_ID, LIKE ORACLE
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMV_TABLE='provincia';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_ID, DMV_TABLE, DMV_COL00, DMV_COL01) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', '1', 'Araba');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_ID, DMV_TABLE, DMV_COL00, DMV_COL01) VALUES (HIBERNATE_SEQUENCE.nextval, 'provincia', '2', 'Albacete');

Property Group xml definition. If the document content where the Property Group is assigned match a "provincia", then is offered as suggestion:

 <select label="Provincia" name="okp:provincia" type="simple" 
      	table="provincia" suggestion="com.openkm.form.suggestion.DocumentContentTokenizerSuggestion"
        optionsQuery="select $pro_id, $pro_nombre from DatabaseMetadataValue dmv where dmv.table='provincia'"/>

Option

  • label: The text which describes the component. Required.
  • name: This is the name of the component. You don't should put two buttons in the same form with the same name. Required.
  • validate: Can be "true" or "false". Indicates if the button shows a validation dialog when clicked. Defaults to "false".

Button

This form element only make sense in the workflow forms.xml file.

  • label: The text which describes the component. Required.
  • value: This is the value of the option to be selected. Required.
  • confirmation: Indicates if the option is selected by default or not. This is the message to be shown.
  • transition: If present, process instance token will follow the indicated transition.
  • style: The icon style to be used when painting the button. Since workflow-forms-2.3.dtd.

Separator

Represent a way to draw a separator to group different elements.

  • label: The text which describes the component. Required.
  • name: This value is used to access the value selected by the user. Required.

Text

Print a text which can contain HTML tags.

  • label: The text which describes the component. Required.
  • name: This value is used to access the value selected by the user. Required.

Validator

Can be used several validators with form elements. Available validators are:

  • req ( indicaques required )
  • alpha ( indicates alphanumeric )
  • dec (indicates decimal )
  • num (indicates numeric )
  • email
  • url
  • maxlen ( indicates max length )
  • minlen ( indicates min length )
  • lt (indicates less to )
  • gt ( indicates greater than
  • min ( indicates min value )
  • max ( indicates max value )
  • regexp ( regular expression )

Nota clasica.png maxlen, minlen, lt, gt, min, max and regexp allows parameters

Example

Define input with decimal value required ( can not be empty )

<input label="Importe" name="okp:importe">
    <validator type="dec"/>
    <validator type="req"/>
    <validator type="maxlen" parameter="6"/>
</input>

Download

Used to download documents:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.
  • width: The width of the component. Defaults to browser default HTML input width.
  • height: The height of the component. Defaults to browser default HTML input height.
  • data: Here you can specify value for this component from workflow.

Should contain one or more node elements which represent the document to download:

  • label: The text which describes the document. Required.
  • path: The path to the document.
  • uuid: The uuid of the document (preferred).

Upload

Used to upload documents:

  • label: The text which describes the component. Required.
  • name: This value is used to access the value typed by the user. Required.
  • width: The width of the component. Defaults to browser default HTML input width.
  • height: The height of the component. Defaults to browser default HTML input height.
  • folderPath: The folder path where the document will be stored.
  • folderUuid: The folder uuid where the document will be stored.
  • documentName: The forced name of the uploaded document.
  • documentUuid: The uuid of the document to be updated.
  • type: If the uploaded document will create a new one or update an existing one. Possible values: create, update.
  • data: Here you can specify value for this component from workflow.

If you want to upload a new document, then should set folderPath or folderUuid, optionally documentName if we want to force the document name. The default type is create, so no need to set.

If you want to update an existing document, then should set documentUuid and put type to update.