Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 84326 invoked from network); 28 Jul 2003 19:59:07 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 28 Jul 2003 19:59:07 -0000 Received: (qmail 6305 invoked by uid 97); 28 Jul 2003 20:01:47 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@nagoya.betaversion.org Received: (qmail 6298 invoked from network); 28 Jul 2003 20:01:46 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 28 Jul 2003 20:01:46 -0000 Received: (qmail 82364 invoked by uid 500); 28 Jul 2003 19:58:45 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 82352 invoked from network); 28 Jul 2003 19:58:45 -0000 Received: from unknown (HELO stbw2k.stbedm.silvacom.com) (64.141.49.18) by daedalus.apache.org with SMTP; 28 Jul 2003 19:58:45 -0000 Received: from p0061 ([192.168.2.114]) by stbw2k.stbedm.silvacom.com with Microsoft SMTPSVC(5.0.2195.2966); Mon, 28 Jul 2003 13:58:50 -0600 From: "Yansheng Lin" To: "'Struts Users Mailing List'" Subject: RE: Validation question Date: Mon, 28 Jul 2003 13:58:50 -0600 Keywords: Struts Maillist Message-ID: <00ae01c35542$a9f42c60$7202a8c0@stbedm.silvacom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: Importance: Normal X-OriginalArrivalTime: 28 Jul 2003 19:58:50.0389 (UTC) FILETIME=[A9F19450:01C35542] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Try errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.userNotFound", "userName"); -----Original Message----- From: Bailey, Shane C. [mailto:SHANE.C.BAILEY@saic.com] Sent: July 28, 2003 1:37 PM To: struts-user@jakarta.apache.org 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: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org