Author: Anthony Eden
FormProc supports an
include element in the formproc.xml configuration file. Included files can include any elements which are used in the formproc.xml configuration. The file format is XML.
The following configuration is taken from the example application which ships with the FormProc distribution.
<?xml version="1.0" encoding="ISO-8859-1"?>
This is required at the begining of every XML document. You can change the encoding value if you need to include foreign characters in your configuration.
<!-- Configuration file for a formproc FormManager --> <config>
The first line is a comment. None of the comments shown here are required, but they can be helpful. The second line signifies the start of the FormProc configuration.
This tag begins the definition of a shared validator. Shared validators are configured once in the formproc.xml configuration and then can be used throughout the form configurations. Defining validators as shared validators promoted reuse.
This tag specifies that the validator is a group validator. Group validators can hold any number of nested child validators. Group validators can also hold other group validators, providing unlimited nesting of validators.
<validator type="rule"> <rule>org.formproc.example.IsIntRule</rule> <error>Valid number required</error> <error lang="fr">L'âge valide a exigé.</error> </validator>
The first validator in the group is a rule validator. Rule validators must implement the
org.formproc.validation.Rule interface. Validator definitions will often include configuration information for the validator as well.
<validator type="expression"> <pattern>[1-9][0-9]*</pattern> <error>Age must be 1 or greater</error> </validator>
The second and last validator in the group is a regular expression validator. The regular expression validator attempts to match the submitted data against the specified pattern. FormProc uses the Jakarta ORO regular expression library to provide expression matching.
These two lines close the group validator and the shared validator definition.
<shared-validator name="username"> <validator type="class" classname="org.formproc.example.UsernameValidator"> <error resource="org.formproc.example.ExampleResourceBundle">username.error</error> </validator> </shared-validator>
The next shared validator is a class validator. Class validators must extend from the
org.formproc.validation.Validator base class and must implement any abstract methods in that base class. This validator is an example validator which is provided with the FormProc distribution.
<shared-validator name="password"> <validator type="script"> <script>PasswordValidator.py</script> <error>Passwords must be at least 8 characters.</error> </validator> </shared-validator>
The final shared validator uses a Python script to validate the submitted value. FormProc supports using any BSF supported scripting language as a validator.
This final tag closes the included configuration.