Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Description

The custom input fields allows you to dynamically add or remove fields from the UserInputPanel with the click of a button.
The variable attribute defined for the custom field saves the number of rows submitted, (If two rows are submitted, variable would have value of 2).
The variable defined for the nested fields will become <variable>.<row_number> ( where the row number starts from 1 ).

Columns

<col> tags are used to add columns, they contain a field to be displayed.
Columns tags are nested within the <field type="custom" ... > tags.
Column tags may contain a validator that will validate based on all the values in the column.
The fields defined within the column tags can be defined exactly the same way as if you to define the field on its own, and can contain its own validation.
Note that the conditionid attribute for fields defined within the column tags are currently not supported.

Attributes

Attribute

Usage

RequiredDefault Value
variableDefines the variable that will hold the number of rows submitted.Yes 

minRow

Defines the minimum amount of rows that must be displayed.
This value should be less than or equal to the value in maxRow.
No1

maxRow

Defines the maximum amount of rows that must be displayed.
This value should be greater than or equal to the value in minRow.

No5

conditionid

If the condition evaluates to show this field, otherwise hide this field.NoEvaluates to true if undefined

 

Validators

Attribute

Usage

com.izforge.izpack.panels.userinput.validator.UniqueValidatorValidate that all values in a column are unique

If you are making your own column validator have a look at the source for UniqueValidator. You will realize that the values come in as a comma separated string.

Currently, there cannot be used nested validators for the single <field> elements, they will be ignored.

You can just use a per-column validator validating a comma-separated input like described above.

Example

In the example below we define a custom field that that has three columns and atleast one row. The user may add up to three rows.
The first column will contain a combo box to select one or more creature types. It also validates that the selected creatures must be unique. (Ex. Mew cannot be chosen twice)
If creatures Mew and Pikachu were selected, it would be saved in creature.type.1 and creature.type.2 respectively.
The second column is similar to the first column except this combo box allows you to select a colour for your creature.
The third column specifies a text field for the user to submit a name for the selected creature. For each individual text field it validates that it is not empty.

 <field type="custom" minRow="1" maxRow="3" variable="creature.count">
    <spec>
        <col>
            <field type="combo" variable="creature.type" summaryKey="creature.type">
                <description id="creature.type"/>
                <spec id="creature.type">
                    <choice id="creature.type.1" value="Bulbasaur"/>
                    <choice id="creature.type.2" value="Charmander"/>
                    <choice id="creature.type.3" value="Geodude"/>
                    <choice id="creature.type.4" value="Mew"/>
                    <choice id="creature.type.5" value="Pikachu"/>
                    <choice id="creature.type.6" value="Squirtle"/>
                </spec>
            </field>
            <validator class="com.izforge.izpack.panels.userinput.validator.UniqueValidator" id="creature.unique" />
        </col>
        <col>
            <field type="combo" variable="creature.colour">
                <description id="creature.colour"/>
                <spec id="creature.colour">
                    <choice id="creature.colour.1" value="Blue"/>
                    <choice id="creature.colour.2" value="Green"/>
                    <choice id="creature.colour.3" value="Indigo"/>
                    <choice id="creature.colour.4" value="Orange"/>
                    <choice id="creature.colour.5" value="Red"/>
                    <choice id="creature.colour.6" value="Violet"/>
                    <choice id="creature.colour.7" value="Yellow"/>
                </spec>
            </field>
        </col>
        <col id="creature.name">
            <field type="text" variable="creature.name" summaryKey="creature.name">
                <spec id="creature.name" size="10"/>
                <validator class="com.izforge.izpack.panels.userinput.validator.NotEmptyValidator" id="creature.name.empty" />
            </field>
        </col>
    </spec>
</field>
  • No labels