Results 1 to 3 of 3

Thread: Custom validation rules and internationalization

  1. #1
    Join Date
    Aug 2004
    Posts
    229

    Default Custom validation rules and internationalization

    I've created a custom Constraint and want the resulting error message (as it appears in a TitledPageApplicationDialog) to be looked up via the standard internationalization message API (aka, I'll put the actual text in my messages.properties file). I did the "let's try this and see if it works" things and had the toString() method on my Constraint implementation return this:
    Code:
              public String toString()
              {
                return "constraint.myconstraint.name";
              }
    I then placed this in my messages.properties:
    Code:
    constraint.myconstraint.name=my constraint message
    No dice - "constraint.myconstraint.name" was output rather than "my constraint message". I started to delve into the whole validation error message code, but realized it is quite involved and thought I'd ask here first. How should I go about internationalizing my constraint violation message?

    Thanks,
    Andy

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Andy,

    Have your constraint implement TypeResolvable. There is a AbstractTypeResolvableConstraint helper. TypeResolvables automatically get resolved in Spring message sources.

    Let me know how it goes. I need to turn my attention to rules validation again - Ollie pointed out several weaknesses as current: for exmample, appropriate rule firing for constraints that effect more than one property.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Aug 2004
    Posts
    229

    Default

    It worked! Thanks!

    - Andy

Similar Threads

  1. declarative validation rules in Spring
    By tentacle in forum Container
    Replies: 10
    Last Post: Jan 31st, 2006, 07:36 AM
  2. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  3. Rules-Based Validation - Does this exist?
    By leask in forum Container
    Replies: 2
    Last Post: Sep 28th, 2005, 05:37 AM
  4. Domain Object Validation
    By lhilden in forum Architecture
    Replies: 4
    Last Post: Dec 14th, 2004, 07:00 AM
  5. Rules Source
    By ulil in forum Swing
    Replies: 1
    Last Post: Oct 8th, 2004, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •