Validation _without_ looking up keys in resource bundles

2006-10-11 Thread Stuart Robertson

I see that Commons Validator now supports this as an option.  For
applications (and whole companies) which aren't concerned about i18n it
would be very nice to have less moving pieces and place the name of the
field directly into validation.xml rather than referencing a key into a
resource bundle.

Is this possible in Struts 1.3.5?  Looking at the source for FieldChecks I
don't see how it is, but hopefully the venerable Struts allows itself to be
used in this way.

Any suggestions?

Thanks,

Stu


Re: Validation _without_ looking up keys in resource bundles

2006-10-11 Thread Stuart Robertson

Ah ha.  Found it.  Looks like the dev guys accounted for this.

You can see how in org.apache.struts.validator.Resources.

public static ActionMessage getActionMessage(Validator validator,
   HttpServletRequest request, ValidatorAction va, Field field) {
   Msg msg = field.getMessage(va.getName());

   if ((msg != null)  !msg.isResource()) {
   return new ActionMessage(msg.getKey(), false);
   }

So if you've configured your validation.xml field entry to indicate that the
message isn't a resource, Struts creates an ActionMessage which interprets
it as a literal value, not as a key into a resource bundle.

Certainly is nice to have the i18n option when you need it, but when you
know you don't, it's quite a bit of clutter to support.

Thanks!

Stu