You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Siggelkow, Bill" <bi...@mirant.com> on 2001/07/17 15:00:24 UTC
RE: Problem when Form-Validation adds ActionErrors
You need to specify an "input" attribute for your action that points to your
jsp page.
The input attribute identifies the page to go back to when errors occur ...
So your action mapping would look like ...
<action path="/addrequest"
type="unizh.ifi.betx.ui.actions.AddRequestAction"
name="addRequestForm"
validate="true"
input="/betx/account.jsp">
<forward name="failure" path="forward.addrequest.failure"/>
<forward name="success" path="forward.addrequest.success"/>
</action>
Check out the struts-config DTD ... it is well commented.
-----Original Message-----
From: Hajo Hindriks [mailto:hajo.hindriks@switzerland.org]
Sent: Tuesday, July 17, 2001 9:32 AM
To: struts-user@jakarta.apache.org
Subject: Problem when Form-Validation adds ActionErrors
Hi all,
I have a form in s jsp that is build with the commponents tags. I use
classicLayout and define the form in the body-area. This are my declarations
in the struts-config:
<form-beans>
<form-bean name="addRequestForm"
type="unizh.ifi.betx.ui.forms.AddRequestForm"/>
</form-beans>
<action path="/addrequest"
type="unizh.ifi.betx.ui.actions.AddRequestAction"
name="addRequestForm"
validate="true">
<forward name="failure" path="forward.addrequest.failure"/>
<forward name="success" path="forward.addrequest.success"/>
</action>
in AddRequestForm I do the following validation:
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((login == null) || (login.length() < 1)) {
errors.add("login", new
ActionError("error.addrequest.login.required"));
}
if ((fullname == null) || (fullname.length() < 1)) {
errors.add("fullname", new
ActionError("error.addrequest.username.required"));
}
if ((email == null) || (email.length() < 1)) {
errors.add("email", new
ActionError("error.addrequest.email.required"));
}
if ((passwort == null) || (passwort.length() < 1)) {
errors.add("passwort", new
ActionError("error.addrequest.password.required"));
}
System.out.println ("Validate: " + errors.size() + " errors.");
return errors;
}
When I leave a text-field emty I get the following output on the consol from
tomcat (integrated with JBoss):
[EmbeddedTomcatSX] Validate: 3 errors.
2001-07-17 01:25:35 - Ctx( /betx ): 500 R( /betx + /addrequest.do + null) No
input attribute for mapping path /addrequest
If I complete the form it is send to addrequest.do and the action.perfrom()
method is called. When there are ActionErrors I want to redisplay the form
which is defined in /betx/accounts.jsp.
What do I have to change?
Thanks a lot
Hajo