Announcement Announcement Module
Collapse
No announcement yet.
Custom validation rules and internationalization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      It worked! Thanks!

      - Andy

      Comment

      Working...
      X