jump to navigation

Struts2: Using validation with fileUpload interceptor July 26, 2007

Posted by maxmil in : struts2 , add a comment

Just a note to remind myself that when using the struts fileUpload interceptor you cannot include the default stack. If you need validation you should do something like this.

<action name="saveFiles" method="saveFiles"
<interceptor-ref name="fileUpload" />
<interceptor-ref name="basicStack"/>
<interceptor-ref name="validation"/>

Modifying struts2 validation templates July 24, 2007

Posted by maxmil in : struts2 , add a comment

I found that the default xhtml templates validation gave errors in firefox (https://issues.apache.org/struts/browse/WW-2058). In order to modify the templates you can copy the “template” folder from the struts jar to your web application root.

However the struts/xhtml/validation.js will still be served from the struts jar. In order to avoid this you should overwrite the line that imports the js in template/xhtml/form-validate.ftl.

The line i have added is as follows

<script type="text/javascript" src="${base}/template/xhtml/validation.js"></script>

@CreateIfNull bug in Struts 2.0.8 and Webwork 2.0.3 July 17, 2007

Posted by maxmil in : struts2 , add a comment

This is a note to remind me that in the struts 2.0.8 release which uses webwork 2.0.3 the automatic object conversion that should be able to create collections of objects directly from html forms has a limitation. Due to a bug in this version of webwork the @CreateIfNull annotation is not being used properly and if the collection is not instantiated with elements prior to parsing the parameters the automatic conversion fails.

Here are the bug references:



At the moment i have no work around other than waiting for a new version. This has been fixed in webwork 2.0.4 but it has not yet been released.

Redirect Action Result and dynamic parameters June 20, 2007

Posted by maxmil in : struts2 , add a comment

This is not in the documentation yet but in order to pass dynamic parameters to a redirect action result you need to include the parameter “parse” with value true.

Heres an example of passing the id of an internal bean doc with the param name id.

<result type="redirect-action">
<param name="actionName">edit</param>
<param name="namespace">/docs</param>
<param name="parse">true</param>
<param name="id">${doc.id}</param>