You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fleetwood, Brett (DCS)" <fl...@saugov.sa.gov.au> on 2007/01/24 23:05:18 UTC

using struts validator for a form-property of type="org.apache.struts.upload.FormFile"

G'day All,

I'm trying to validate a form that contains a

org.apache.struts.upload.FormFile as a form property on a JSP. From the

struts HTML tag-lib I'm using <html:file> in my JSP like this;

    <html:file size="80" property="fileUpload" styleClass="inputfield"
errorStyleClass="inputfielderror" />

and I've set up the form bean like this;

    <form-bean name="documentUploadForm" dynamic="true"
type="au.gov.sa.dcs.dcscommon.ui.struts.form.DcsDynaValidatorForm">

        <form-property name="fileUpload"
type="org.apache.struts.upload.FormFile"/>

        <form-property name="documentIndex" type="java.lang.String" />

        <form-property name="personIndex" type="java.lang.String" />

        <form-property name="documentType" type="java.lang.String" />

        <form-property name="documentAttributeDescription"
type="java.lang.String" /> 

    </form-bean>

where the DcsDynaValidatorForm extends the DynaValidatorForm.

I'm trying to validate the form by checking the text of the FormFile

object to see if its blank. This is what i've tried in validation.xml

but it doesn't get picked up;

    <field property="fileUpload" depends="required" >

        <arg key="File" resource="false" position="0" />

    </field>

I'm quite new to this and if i've omitted anything then please let me
know. 

Thanks in advance,

Brett.