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


Alexander - what happens on failure is based on the "input" attribute of the action mapping. Right now you have it set to msys.categories-edit, which I would guess is a tile definition. If you go directly to the tile definition then no, the execute() method is not called, because you bypassed the action.


You would have to set the input attribute to be /categories-edit.do to get the execute() method to run again.

This may not work either because that action always validates the form data. You most likely need to setup a "loader" action that just does the CATEGORY-TREE loading, and forward back to that when there is an error.

If you wanted you could also setup your own ActionForm (don't use DynaForms) and have the validate() method of the ActionForm check whether it should actually validate or not. If you choose this option search on the archives a bit, I'm pretty sure there is info about doing something like that.


Matt

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



Reply via email to