Hello,
I've been using the Struts Validator (nightly build of November) with no
problems for a few months (great work!).
Now I need to call the validation method of a specific "nested form" based
on a condition:
ParentForm
+useChild: boolean
+getChildForm:ChildForm
If useChild returns true, I want to call the validate(mapping, request) of
ChildForm (ie the nested form).
I thought that the validator only needed the "mapping.getAttribute()" (name
of the ActionForm) to perform the validation so I tried with the following
(ugly, I know):
if (parentForm.useChild()) {
ActionMapping newMap = new ActionMapping();
newMap.setAttribute("childForm");
ActionErrors errors = parentForm.getChildForm().validate(newMap,
request);
}
The configuration is extremely basic:
- In struts-config.xml:
<form-bean name="childForm"
type="com.company.ChildForm"/>
- In validation.xml:
<form name="childForm">
...
</form>
I'm getting a NullPointerException in the validator's code.
What am I doing wrong? Is this a good way to handle the problem (I doubt
it...)? Any suggestions?
Thanks.
Andrej