Load resource bundle and get the message from bundle:

ResourceBundle labels =
           ResourceBundle.getBundle(
               "properties/ApplicationResources",
               (Locale) request.getSession().getAttribute(
Globals.LOCALE_KEY));

String orgName = labels.getString("employer.orgName");

errors.add("orgName", new ActionMessage("employer.requiredfield", orgName));

HTH,

On 5/24/06, navin mca <[EMAIL PROTECTED]> wrote:

Hi,


  Follow these steps.

  1. Define ApllicationResources_locale specific property file.

  2. add the message keys to thse different locale specific property file.

  3. in Jsp file set the locale based on the reuest parameters.
  with
  <fmt:setlocale tag or set manually locale

  Hope this will help u.



Jorge Martí(r)Cuervo <[EMAIL PROTECTED]> wrote:
  Hi all,

i want to use externalized messages in the validation errors of a
ActionForm subclass.

I have this code:

[...]
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {

ActionErrors errors = new ActionErrors();

/*
* required fields
*/
if (orgName == null || orgName.equals("")) {
errors.add("orgName", new
ActionMessage("employer.orgName.requiredfield"));
}
[...]

and works pretty good, but i want to use ActionMessages with a parameter
with the name of the required field. For instance:

[...]
if (orgName == null || orgName.equals("")) {
errors.add("orgName", new

ActionMessage("employer.requiredfield", "employer.orgName"));
}
[...]

But in jsp view, it generates

"employer.orgName is required"


I want to get the ResourceBundle to "translate" the employer.orgName to
the value assigned in .properties file.

How can i do it?

thanks

--
;-)
____________________________________
Jorge Martin Cuervo
Analista Programador

Outsourcing Emarketplace
deFacto Powered by Standards

email
voz +34 985 129 820
voz +34 660 026 384
____________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Thanks and Regards,
Novin Jaiswal
+919890089443(M)
+912039511388(H)
+912026901306(O) direct
+912026982424 Extn:1306

---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.




--
Vinit Sharma
IBM

Reply via email to