Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added documentation for toVariable

...

<field type="..." variable="...">
    <spec>
        ...
        <processor class="fully.qualified.ProcessorClassName" [backupVariable="..."] [toVariable="..."]>
            <configuration>
                <whatever-param-name>...</whatever-param-name>
                <another-param2-name>...</another-param2-name>
                ...

            </configuration>
        </processor>
    </spec>
    <validator class="fully.qualified.ValidatorClassName" txt="..." id="..."/>
</field>

...

<field type="..." variable="...">
    <spec>
        ...
        <processor class="fully.qualified.ProcessorClassName" [backupVariable="..."] [toVariable="..."]>
            <configuration>
                <param name="whatever-param-name" value="..."/>
                <param name="another-param2-name" value="..."/>
                ...

            </configuration>
        </processor>
    </spec>
    <validator class="fully.qualified.ValidatorClassName" txt="..." id="..."/>
</field>

...

  • backupVariable (optional):
    a variable holding the original value entered by the user before processing took place
    This variable is not present before the processor action actually happens.
  • toVariable (optional):
    a variable to store the processed value and leave the original value unchanged.
    This variable is not present before the processor action actually happens.

Built-in processors

Build-in processors are available in IzPack in the package com.izforge.izpack.panels.userinput.processor.

...

Code Block
languagexml
titleResource UserInputSpec.xml
  <panel id="panel.password">
    <field type="title" txt="Password panel" id="panel.password.title" />
    <field type="password" align="left" variable="keystore.password">
      <spec>
        <pwd txt="Keystore Password:" size="25" set=""/>
        <pwd txt="Retype Password:" size="25" set=""/>
        <processor class="custom.processor.Md5Processor" toVariable="keystore.password.md5" />
        <processor class="com.izforge.izpack.panels.userinput.processor.PasswordEncryptionProcessor" backupVariable="keystore.password.plain">
          <configuration>
            <encryptionKey>MySecretKey</encryptionKey>
            <algorithm>AES</algorithm>
          </configuration>
        </processor>
      </spec>
      <validator class="com.izforge.izpack.panels.userinput.validator.PasswordEqualityValidator"
                 txt="Both keystore passwords must match." id="key for the error text"/>
    </field>
  </panel>

The above panel shows two user input fields for passwords. Both passwords entered must match, which is ensured by the PasswordEqualityValidator when leaving the panel. After the validation has passed, the plain password the user entered is encrypted with the encryption key and algorithm defined as processor parameters. The encrypted result of this operation is stored in the field variable keystore.password, the variable keystore.password.md5 holds a md5 hash of the value . To not loose the plain password the user entered we defined additionally the (optional) backup variable keystore.password.plain, which holds the original user value and can be used for further post-processing during the installation.