Hi all,
I got a problem, I want to validate several Form in a
DispatchAction. But, this Action is called after a validation of an other
type of form. I got a Null Exception Pointer when I validate through my
DispatchAction. Somebody has an idea, how I can validate without problem.
Here an extract of my code :
The action mapping ....
<action path="/createMasterFromFile"
type="plateinv.actions.plate.MPCreateAction"
name="plateCreationForm"
parameter="method"
validate="true"
input="tiles.plate.master.create.option">
<forward name="createFromFile"
path="tiles.plate.master.create.confirmationMP"/>
<forward name="createFromFileMPDP"
path="tiles.plate.master.create.confirmationMPDP"/>
</action>
public class MPCreateAction extends DispatchAction {
.......
public ActionForward createFromFile(ActionMapping mapping,ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
DynaValidatorForm pcf = (DynaValidatorForm) form;
//retrieve the file representation
FormFile file = (FormFile) pcf.get("fileName");
ReadMP rmp = new ReadMP(file.getInputStream());
Collection collMP = rmp.read(); //Collection of MasterPlateForm
Iterator it = collMP.iterator();
while(it.hasNext()) {
MasterPlateForm mpf = ( MasterPlateForm ) it.next();
Enumeration enum = request.getAttributeNames();
mpf.validate( mapping, request ); // Where I call the validate
method
}
return mapping.findForward("createFromFile");
}
}
public class MasterPlateForm extends ValidatorForm {
.....
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
ActionMessages errors = super.validate(mapping,request); // This is
the line where the null pointer exception is called
String method = request.getParameter("method").toString();
if(method.equals("cancel")) {
return null;
} else {
return (ActionErrors) errors;
}
}
}
I wait your ideas !
Charles Gouin-Vallerand
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]