Author: rich
Date: Wed Aug 25 09:59:30 2004
New Revision: 37009

Modified:
   
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
   
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
Log:
Declarative validation annotations (@Jpf.ValidateRequired, 
@Jpf.ValidateMinLength, etc.) can accept message arguments specified as either 
keys or literal text, e.g.,
    @Jpf.ValidateRequired(messageKey="errors.required", arg0="Literal Display 
Name")
    @Jpf.ValidateRequired(messageKey="errors.required", 
arg0Key="displayName.field1")

This checkin fixes the latter case.

DRT: netui (WinXP)
BB: self (linux)



Modified: 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
 Wed Aug 25 09:59:30 2004
@@ -255,15 +255,16 @@
                 
                 if ( arg != null )
                 {
-                    String key = ValidatorConstants.EXPRESSION_KEY_PREFIX + 
arg.getMessage();
+                    String argMessage = arg.getMessage();
+                    String key = arg.isKey() ? argMessage : 
ValidatorConstants.EXPRESSION_KEY_PREFIX + argMessage;
                     argElementToUseClass.getMethod( "setKey", String.class 
).invoke( argElementToUse, key );
                     String isResource = Boolean.toString( arg.isKey() );
                     argElementToUseClass.getMethod( "setResource", 
String.class ).invoke( argElementToUse, isResource );
                     argElementToUseClass.getMethod( "setName", String.class 
).invoke( argElementToUse, ruleName );
                 }
-                else if ( altMessageVar != null ) 
+                else
                 {
-                    altMessageVar = "${var:" + altMessageVar + "}";
+                    altMessageVar = "${var:" + altMessageVar + '}';
                     argElementToUseClass.getMethod( "setKey", String.class 
).invoke( argElementToUse, altMessageVar );
                     argElementToUseClass.getMethod( "setResource", 
String.class ).invoke( argElementToUse, "false" );
                     argElementToUseClass.getMethod( "setName", String.class 
).invoke( argElementToUse, ruleName );

Modified: 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
    Wed Aug 25 09:59:30 2004
@@ -42,7 +42,6 @@
         {
             _message = message;
             _isKey = isKey;
-            assert ! isKey;     // don't support this for now
         }
 
         public String getMessage()

Reply via email to