Thanks.
One minor change needed, the actual value needed to be passed and not the
name of the of a form bean:
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.userNotFound",
nameOfUserToUpd);
-----Original Message-----
From: Yansheng Lin [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 3:59 PM
To: 'Struts Users Mailing List'
Subject: RE: Validation question
Try
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.userNotFound",
"userName");
-----Original Message-----
From: Bailey, Shane C. [mailto:[EMAIL PROTECTED]
Sent: July 28, 2003 1:37 PM
To: [EMAIL PROTECTED]
Subject: Validation question
I have been using the validator plug-in so long now that I can't remember
how this simple thing works:
In an action I determine that the user (as described in a request parameter)
is not in the DB so I want to return an error message to the user
with the username they entered incorrectly. Here is a code snipet:
Action code:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String nameOfUserToUpd =
request.getParameter("username");
DynaActionForm editUserForm = (DynaActionForm)form;
UpdateUserSession updSession = new
UpdateUserSession(nameOfUserToUpd);
User user = updSession.getUser();
if(user==null)
{
//Add error
errors.add("userName", new
ActionError("errors.userNotFound"));
saveErrors(request, errors);
//Set the form variable because the
username came in from a "GET" not a "POST".
editUserForm.set("userName",
nameOfUserToUpd);
return
(mapping.findForward("userNotFound"));
}
...
}
properties file:
errors.userNotFound='{0}' was not found.
On the page mapped to "userNotFound" it displays as: '{0}' was not found
I thought by having the first parameter to errors.add() with the same name
as an attribute on the form bean it would automatically fill in '{0}' ????
This is way past validation and has nothing to do with what is in
validation.xml so I can't specify arg0 value.
How do I accomplish what I am trying to do?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]