struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hegarty <matt_hega...@totalise.co.uk>
Subject validator not working with tiles?
Date Mon, 26 Apr 2004 20:20:53 GMT
Hello All

I recently modified my code to include Tiles and since doing so have
found that the Struts validator appears not to perform validation.

When submitting a form with a single 'required' rule, the form is
submitted seemingly without any validation performed on this field.
Instead the action just forwards as though the validation were
successful, and displays an entry with an empty (invalid) field.

The form does work fine when entering valid, data so the fields are
being read correctly.

I also have a form which DOES NOT use tiles, and this validates fine
with the Struts validator.

Everything else seems to work ok, apart from this missing validation.

Relevant sections are posted below:

FROM struts-config.xml:

<form-bean name="fooForm" type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="id" type="java.lang.String" />
    <form-property name="name" type="java.lang.String" /> 
</form-bean>

<action path="/PrivateNewFooSubmit"
    type="my.actions.PrivateFooAction"
    name="fooForm" 
    scope="request" 
    input="private.newFoo" 
    validate="true"
    parameter="method">
    <forward name="success" path="/PrivateViewFoos" redirect="false" />
</action>


<plug-in className="org.apache.struts.tiles.TilesPlugin">
    <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
    <set-property property="definitions-debug" value="2"/>
    <set-property property="definitions-parser-details" value="2"/>
    <set-property property="definitions-parser-validate" value="true"/>
</plug-in>

 
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

>From validation.xml:

<form-validation>
    <formset>
        <form name="fooForm">
            <field property="name" depends="required">
                <arg0 key="prompt.foo.name"/>
            </field>
        </form>
    </formset>
</form-validation>

>From validator-rules.xml:

<form-validation>
    <global>
    <validator name="required"
        classname="org.apache.struts.validator.FieldChecks"
        method="validateRequired"
        methodParams="java.lang.Object,
        org.apache.commons.validator.ValidatorAction,
        org.apache.commons.validator.Field,
        org.apache.struts.action.ActionErrors,
        javax.servlet.http.HttpServletRequest"
        msg="errors.required"
    />
    </global>
</form-validation>


>From the point of submit, the logs contain the following, which looks
like the validator is not being called at all.

DEBUG (RequestProcessor.java:225) - Processing a 'POST' for path '/PrivateNewFoo'
DEBUG (RequestUtils.java:764) -  Looking for ActionForm bean instance in scope 'request' under
attribute key 'fooForm'
DEBUG (RequestUtils.java:824) -  Creating new DynaActionForm instance of type 'org.apache.struts.validator.DynaValidatorForm'
DEBUG (RequestUtils.java:829) -  --> DynaActionForm[dynaClass=fooForm,name=,id=]
DEBUG (RequestProcessor.java:372) -  Storing ActionForm bean instance in scope 'request' under
attribute key 'fooForm'
DEBUG (RequestProcessor.java:813) -  Populating bean properties from this request
DEBUG (RequestProcessor.java:305) -  Looking for Action instance for class my.actions.PrivateFooAction
DEBUG (RequestProcessor.java:315) -   Returning existing Action instance
DEBUG (TilesRequestProcessor.java:304) - processForwardConfig(/PrivateViewFoos.do?method=view,
false)

Hope someone can help with this!

thanks
Matt


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message