Try: MessageResources resources = getServlet().getResources(); resources.getMessage("emailAddressLabel");
If your bundle is localized, you'll have to get the locale separately and pass that on to the getMessage. Locale loc = (Locale)request.getSession().getAttribute( org.apache.struts.action.Action.LOCALE_KEY); resources.getMessage(loc, "emailAddressLabel"); Cheers, Bruce "Silvert, Stan" wrote: > > I need to access the Struts application resource bundle from an ActionForm. > Here is why: > > During validation, I want to check for a required field such as email > address. In my system, "Email Address" is always referred to from a > resource bundle so that I can localize properly. > > So, my English language resource bundle looks something like this: > > requiredFieldError = <li>{0} is a required field</li> > emailAddress = Email Address > > In my ActionForm validate(mapping, request) method, I would like to say > something like: > > ActionErrors errors = new ActionErrors(); > if (notFilledIn(this.emailAddress)) { > errors.add("emailAddress", > new ActionError("requiredFieldError", !!! resource that > "emailAddress" points to !!!); > } > > The question is, how do I get at the resource that "emailAddressLabel" > points to, so that I can localize my ActionError? > > My solution so far is to subclass ActionServlet and make the > MessageResources available as a static member. But, this seems like a hack. > > Is there a better way to get to the MessageResources from an ActionForm? > > Thanks in advance for your help, > > Stan Silvert > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>