Struts validate method: I18N error messages

Discussion in 'Java' started by Klaus, Jul 2, 2003.

  1. Klaus

    Klaus Guest

    I have an error message like "{0} is ..." (Resources).

    See code below:
    The part "key.x.z" is taken from the resource bundle (fine)
    The replacment {0} is displayed as it is: "key.x.label" (bad)
    => How can I make the second part being internationlized too?

    I work-around the problem by manually getting the bundle by using
    PropertyResourceBundle. I do not like it, because when I change the
    resource bundle in struts-config.xml the Java code becomes
    inconsistent with the config file.

    Possible solutions:
    Directly access the default bundle from within validate, but how?

    Code Example:
    =============
    public ActionErrors validate(ActionMapping m, HttpServletRequest r) {
    ActionErrors errors = new ActionErrors();
    if (....)
    errors.add("person", new ActionError("key.x.z", "key.x.label"));
    return errors;
    }
     
    Klaus, Jul 2, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Thielen

    sample struts w/ I18N and validator

    David Thielen, Aug 2, 2003, in forum: Java
    Replies:
    0
    Views:
    463
    David Thielen
    Aug 2, 2003
  2. Rhino
    Replies:
    2
    Views:
    5,317
    Filip Larsen
    Dec 22, 2003
  3. eeyimaya

    Struts....I18N and encoding?

    eeyimaya, Feb 17, 2005, in forum: Java
    Replies:
    1
    Views:
    3,390
    writeOnceDebugEverywhere()
    Feb 17, 2005
  4. los
    Replies:
    29
    Views:
    1,683
    Chris Uppal
    Sep 25, 2005
  5. Tim Slattery

    Struts I18N

    Tim Slattery, Mar 21, 2013, in forum: Java
    Replies:
    2
    Views:
    474
    Tim Slattery
    Mar 21, 2013
Loading...

Share This Page