File Chooser Field

This field allows the user to select a file from the file system. Text can be added before the selection or a static text element can be added to display above the selection box (a little more visually appealing).

The file field supports the following attributes for the <spec> element:

Name

Required

Description

Value

Name

Required

Description

Value

allowEmptyValue

no

If set true, no file has to be selected and the box can be left empty.

true, false default: false

mustExist

no

If set true, the given file is required to exist.

true, false default: true

fileext

no

File extension to be forced. This will be used as mask in the FileChooserDialog.

The fileextdesc attribute must be set additionally to activate this.



fileextdesc

no

The description of the file extension. This will be used in the file extension mask in the FileChooserDialog.
There can be used a translation key, it is translated along with the UserInputPanel translations separately.

The fileext attribute must be set additionally to use this.





1 2 3 4 5 6 7 <field type="file" align="left" variable="the.file"> <spec txt="" size="25" set=""/> </field> <field type="staticText" align="left" txt="Existing SSL keystore to import:"/> <field type="file" align="left" variable="existing.ssl.keystore"> <spec txt="" size="25" default="$myconfig"/> </field>



 

Pressing 'Next' without a file selected show the following message:

 

Messages for the file field can be customized by creating a custom lang pack and overriding the following values (attribute values wrapped for readability):

1 2 3 4 <str id="UserInputPanel.file.nofile.message" txt="You must select a valid file."/> <str id="UserInputPanel.file.nofile.caption" txt="No File Selected"/> <str id="UserInputPanel.file.notfile.message" txt="The file you have chosen either does not exist or is not valid."/> <str id="UserInputPanel.file.notfile.caption" txt="Invalid File"/>



If you wish to have a file field that can be used optionally, use the attribute allowEmptyValue="true" inside of the nested spec element:

1 2 3 <field type="file" variable="the.file"> <spec txt="" size="25" allowEmptyValue="true" set=""/> </field>



This supports a <description> element that can be used to provide information about the purpose of the file field.
See Fields documentation for more detail.

1 2 3 4 <field type="file" variable="password.file"> <description id="password.file.info" txt="Where would you like to place your password file?/>  <spec size="25"/> </field>



Note:

Mixing file fields with other fields that have text in front of them can lead to formatting (layout) issues. Placing these types of elements on different panels can provide a much better user experience.