Thanks a lot Niall. I does work..We were displaying our errors in the jsp with <logic:messagesPresent> <bean:message key="messages.header" /> <html:messages id="error"> <bean:write name="error" filter="false"/> </html:messages> </logic:messagesPresent>
And assumed that, errors can only be displayed with GLOBAL_ERRORKEY. Thanks, Ganesh. On 1/4/06, Niall Pemberton <[EMAIL PROTECTED]> wrote: > > OK, you need to associate the message with the "lastName" property and not > ActionErrors.GLOBAL_ERROR, so something like... > > if ((lastName == null) || (lastName.trim().length() == 0)) { > errors.add("lastName", new ActionMessage(" > error.login.nolastname")); > } > > Niall > > ----- Original Message ----- > From: "RathinaGanesh MeenakshiSundaram" <[EMAIL PROTECTED]> > Sent: Wednesday, January 04, 2006 4:48 PM > > > Niall, > > I do the same thing you say, except that, Iam storing them as " > ActionErrors.GLOBAL_ERROR" > This is what, I have in the validate method .... > > if ((lastName == null) || (lastName.trim().length() == 0)) { > errors.add("ActionErrors.GLOBAL_ERROR", new ActionMessage(" > error.login.nolastname")); > } > > After, I execute the page, when I see the source code it just has the > <input > type="text" class="login"> rather than <input type="text" > class="loginERROR"> > > Any Idea..?? > > Also, what do you mean by "message associated with the "lastName" > property." > This is what, I have for the lastName in Application Resources.properties > > error.login.nolastname=<li class="shorterrormsg" > style="width:220px;"><label > for="lastname" class="errorlabels">Last name</label> is required.</li> > > Thanks, > Ganesh. > > > On 1/3/06, Niall Pemberton <[EMAIL PROTECTED]> wrote: > > > > For the errorStyleClass to be used there need to be a set of > > "ActionMessages" stored under the appropriate key (i.e. > Globals.ERROR_KEY) > > and there needs to be a message for the field in error - i.e. in your > case > > a > > message associated with the "lastName" property. > > > > If your returning an appropriate set of ActionMessages in your > > ActionForm's > > validate method they'll automatically get stored under the right key and > > you > > just need to make sure the property name for the specific message is set > > correctly. If your not doing this then you need to say how you are > > validating. > > > > Also, when you say "it just has the styleClass" - do you mean it is > > rendering <input type="text" class="login"> rather than <input > type="text" > > class="loginERROR">? > > > > Niall > > > > ----- Original Message ----- > > From: "RathinaGanesh MeenakshiSundaram" <[EMAIL PROTECTED]> > > Sent: Tuesday, January 03, 2006 8:24 PM > > > > > > Thanks. > > I figured out the issue. I had a different version of struts in another > > app, > > and somehow that was classloader was picking up that older version.. > > But, still after I get them right, the text field is not picking up the > > errorStyleClass and just has the styleClass, even incase of error..! > > > > Here is my peice of code.. > > <html:text styleClass="login" property="lastName" maxlength="15" > size="28" > > styleId="lastname" errorStyleClass="loginERROR" /> > > > > Please let me know. > > Thanks, > > Ganesh. > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >