Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom Types

    If I create a SimpleType according to the example in the feature explorer, I get a XML parser error due to the document not being well-formed. Moving the SimpleType declarations inside the DataSource tags gives me "No such type 'zip', not processing ..." errors by the Validation class.

    Exactly how / where do I put the SimpleType declarations to make them available to my data source fields?

    Thanks,
    --mgbowman

    #2
    Hi mgbowman,
    The easiest way to do this is to add a "types" block to your dataSource and embed the type definition directly in it.
    For example:

    Code:
    <DataSource
        ID="someDS"
        serverType="sql"
    >
        <fields>
            <field name="itemID"      type="sequence" hidden="true"       primaryKey="true"/>
            <field name="zipcode"         type="zip"     title="Zip Code" required="true"/>
        </fields>
        <types>
            <type ID="zip" inheritsFrom="text">
                <validators>
                    <validator type="regexp" errorMessage="Must be zipcode format"
                               expression="^\d{5}(-\d{4})?$"/>
                </validators>
            </type>
        </types>
    </DataSource>
    This gives you client and server side validation behavior automatically.

    You could also define a SimpleType object in XML as demonstrated in the Feature Explorer example and load it via the isomorphic:XML tag in a JSP. This will work for client side validation only however - the client is aware of the SimpleType but you'd have to add your own separate validation logic to the server if using this approach.

    Comment

    Working...
    X