Your action isn't executed if validation fails. However, the validation is performed on a second request, so the object placed into the scope before the form was presented is no longer there.

If your categories are really relatively static, consider managing them in Application scope rather than request. I often have one or more plugins which initialize common menus like states and provinces or months of the year and place them into the application scope (I like to use the DigestingPlugIn). Your code doesn't look like there's anything particularly request-sensitive about the category tree.

Some people make lists a property of the form itself. This is also one of the core use cases for some kind of view controller registered against the input forward's path, which is one of my goals to implement in a Struts 1.3.x timeframe.

Joe

At 3:09 PM +0100 11/23/04, Alexander Czernay wrote:
I have a simple DynaValidatorForm

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


that is called whtin an action

       <action path="/categories-edit"
           attribute="categoryForm"
           input="msys.categories-edit"
           name="categoryForm"
           scope="request"
           validate="true"
           type="de.sbow.struts.action.Categories.EditAction">
           <forward name="success" path="/categories-edit-finish.do" />
        </action>

that inserts so data into the request inside its execute method

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
// read CategoriesTree and put it into request scope
try {
CategoriesModel categories = new CategoriesModel();
request.setAttribute(Constants.CATEGORY_TREE, categories.getCategories());
} catch (ApplicationException e) {
request.setAttribute(Constants.CATEGORY_TREE, null);
}


return mapping.findForward("success");
}


This works quite well during the form's initial display. But if I enter wrong values so that the validation fails, the CATEGORY_TREE-attribute is missing and thus the JSP-view fails.

Isn't the execute-method called again when the validation fails? Anything else wrong here?

Thanks for any help,
Alexander


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex

Reply via email to