Dear colleague developers,
We are struggling with a problem to get the struts-forms working. It might
be a newbie problem, but it is still difficult to find out which newbie
problem we made. ;-) I included the most important struts problems at the
bottom.
No FAQ/examples/etc. could solve our problem, so I think that it might have
something to do with a more complicated issue.
We want:
Serverside form validation:
1. When an error is added to the ActionErrors we want to display it at the
top (iterate over the list)
2. Show the same form again, and
3. WITH the input (even though it might not be right) shown in the input
fields.
We have:
1. Whenever we raise an error we get the message at the top of the page:
Validation Error
You must correct the following error(s) before proceeding:
And no list of the errors.......
2. We get the same form allright, but with NO VALUES whatsoever.
Guys, WE ARE STUCK. :-(
So any help would be greatly apreciated.
Regards,
Eelco & Angela
****************************************************************************
***********************************************************
here the (stripped) jsp code:
<form:errors/>
<form:form name="sparenform"
type="nl.rabobank.www.rekenmodellen.sparen.SparenActionForm"
action="/rekenmodellen/sparenresult" focus="invoerGetal1">
<form:text property="invoerGetal1" size="10" maxlength="10"/>
</form:form>
here the (stripped) actionclass code:
ActionErrors errorsHTML = new ActionErrors();
errorsHTML = sparenActionForm.checkForm();
if (!errorsHTML.empty())
{
cat.debug("!errorsHTML.empty()");
saveErrors(request, errorsHTML); //request.setAttribute
("sparen.error", errorsHTML);
// return to the original form
return (new ActionForward(mapping.getInput()));
}
else
{
..no errors
}
here the form validator function(in the ActionForm):
public ActionErrors checkForm()
{
ActionErrors errors = new ActionErrors();
/**
* error inleg: getal heeft verkeerde waarde
*/
if (!berekeningtype.equalsIgnoreCase("i") && (inleg <= 0 || inleg >=
1000000))
{
cat.debug("fout gemaakt in inleg");
errors.add("invoerGetal1",new ActionError("inleg moet tussen
de 0 en 1.000.000 zijn !"));
}