You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/02/15 02:12:02 UTC
svn commit: r153878 [1/3] - in incubator/beehive/trunk/netui:
src/compiler/org/apache/beehive/netui/compiler/
src/compiler/org/apache/beehive/netui/compiler/genmodel/
src/compiler/org/apache/beehive/netui/compiler/grammar/
src/compiler/org/apache/beehive/netui/compiler/model/validation/
src/compiler/schema/struts-validator/
src/pageflow/org/apache/beehive/netui/pageflow/annotations/
test/webapps/drt/ test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/
test/webapps/drt/coreWeb/validation/
test/webapps/drt/coreWeb/validation/basicValidation/
test/webapps/drt/coreWeb/validation/messages/
test/webapps/drt/coreWeb/validation/messages/args/
test/webapps/drt/coreWeb/validation/messages/args11/
test/webapps/drt/coreWeb/validation/messages/merge/
test/webapps/drt/coreWeb/validation/messages/merge11/
test/webapps/drt/coreWeb/validation/strutsValidator/
test/webapps/drt/testRecorder/config/ test/webapps/drt/testRecorder/tests/
Author: rich
Date: Mon Feb 14 17:11:54 2005
New Revision: 153878
URL: http://svn.apache.org/viewcvs?view=rev&rev=153878
Log:
This is a contribution from Carlin Rogers, from http://issues.apache.org/jira/browse/BEEHIVE-262 :
ere's a patch file to use to update the declarative validation
to support commons validator v1.1.
- Updated the validator schema to version 1.1.
- Modified the name of the v1.1 validator package for the
XMLBean classes.
- Implemented new message arg annotation and bundle name
attributes.
- Added a grammar class for the array of message arguments.
- Provided support for the ealier, v1.0 validator that is
part of struts 1.1.
- Created a new test for the message args.
- Fixed Jira bug (BEEHIVE-261) for validation merge feature
and added a test.
Thank you Carlin!
DRT/BVT: netui (WinXP)
BB: self (linux)
Added:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java (with props)
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java (with props)
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args/Controller.jpf (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args/index.jsp (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args11/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args11/Controller.jpf (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/args11/index.jsp (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge/Controller.jpf (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge/index.jsp (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge/merge-validation.xml (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge11/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge11/Controller.jpf (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge11/index.jsp (with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/messages/merge11/merge-validation.xml (with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ValidatorMerge.xml (with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ValidatorMerge11.xml (with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ValidatorMsgArgs.xml (with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ValidatorMsgArgs11.xml (with props)
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/LocaleSet.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableEntity.java
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/ValidationModel.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/config.xsdconfig
incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/struts-validator_1_1.xsd
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
incubator/beehive/trunk/netui/test/webapps/drt/build.xml
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/basicValidation/basicValidationController.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/strutsValidator/strutsValidatorController.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/validationController.jpf
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java Mon Feb 14 17:11:54 2005
@@ -55,6 +55,7 @@
public static final String VALIDATE_TYPE_TAG_NAME = "ValidateType";
public static final String VALIDATE_VALID_WHEN_TAG_NAME = "ValidateValidWhen";
public static final String VALIDATE_CUSTOM_TAG_NAME = "ValidateCustomRule";
+ public static final String MESSAGE_ARG_TAG_NAME = "MessageArg";
public static final String BEGIN_ACTION_NAME = "begin";
public static final String JPF_FILE_EXTENSION = "jpf";
@@ -99,6 +100,7 @@
public static final String NESTED_ATTR = "nested";
public static final String LONGLIVED_ATTR = "longLived";
public static final String STRUTSMERGE_ATTR = "strutsMerge";
+ public static final String VALIDATOR_VERSION_ATTR = "validatorVersion";
public static final String VALIDATOR_MERGE_ATTR = "validatorMerge";
public static final String CUSTOM_VALIDATOR_CONFIGS_ATTR = "customValidatorConfigs";
public static final String TILES_DEFINITIONS_CONFIGS_ATTR = "tilesDefinitionsConfigs";
@@ -113,14 +115,10 @@
public static final String RETURN_ACTION_ATTR = "returnAction";
public static final String MESSAGE_ATTR = "message";
public static final String MESSAGE_KEY_ATTR = "messageKey";
- public static final String ARG0_ATTR = "arg0";
- public static final String ARG0_KEY_ATTR = "arg0Key";
- public static final String ARG1_ATTR = "arg1";
- public static final String ARG1_KEY_ATTR = "arg1Key";
- public static final String ARG2_ATTR = "arg2";
- public static final String ARG2_KEY_ATTR = "arg2Key";
- public static final String ARG3_ATTR = "arg3";
- public static final String ARG3_KEY_ATTR = "arg3Key";
+ public static final String MESSAGE_ARGS_ATTR = "messageArgs";
+ public static final String ARG_ATTR = "arg";
+ public static final String ARG_KEY_ATTR = "argKey";
+ public static final String POSITION_ATTR = "position";
public static final String DISPLAY_NAME_ATTR = "displayName";
public static final String DISPLAY_NAME_KEY_ATTR = "displayNameKey";
public static final String METHOD_ATTR = "method";
@@ -208,7 +206,10 @@
public static final String MULTIPART_HANDLER_MEMORY_CLASSNAME = STRUTS_PACKAGE + ".upload.CommonsMultipartRequestHandler";
public static final String MULTIPART_HANDLER_DISK_CLASSNAME = STRUTS_PACKAGE + ".upload.DiskMultipartRequestHandler";
- public static final String ARRAY_TYPE_SUFFIX = "[]";
+ public static final String VALIDATOR_VERSION_ONE_ZERO_STR = "oneZero";
+ public static final String VALIDATOR_VERSION_ONE_ONE_STR = "oneOne";
+
+ public static final String ARRAY_TYPE_SUFFIX = "[]";
public static final String GETTER_PREFIX = "get";
public static final String BOOLEAN_GETTER_PREFIX = "is";
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java Mon Feb 14 17:11:54 2005
@@ -31,6 +31,7 @@
public class MergedControllerAnnotation
{
private String _strutsMerge;
+ private String _validatorVersion;
private String _validatorMerge;
private List< String > _tilesDefsConfigs;
private boolean _nested;
@@ -58,6 +59,9 @@
String strutsMerge = CompilerUtils.getString( controllerAnnotation, STRUTSMERGE_ATTR, true );
if ( strutsMerge != null ) _strutsMerge = strutsMerge;
+ String validatorVersion = CompilerUtils.getEnumFieldName( controllerAnnotation, VALIDATOR_VERSION_ATTR, true );
+ if ( validatorVersion != null ) _validatorVersion = validatorVersion;
+
String validatorMerge = CompilerUtils.getString( controllerAnnotation, VALIDATOR_MERGE_ATTR, true );
if ( validatorMerge != null ) _validatorMerge = validatorMerge;
@@ -122,6 +126,11 @@
public String getStrutsMerge()
{
return _strutsMerge;
+ }
+
+ public String getValidatorVersion()
+ {
+ return _validatorVersion;
}
public String getValidatorMerge()
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties Mon Feb 14 17:11:54 2005
@@ -186,6 +186,8 @@
warning.validate-type-on-same-type = \
This {0}(type={1}.class) annotation has no effect, since the property type is {1}.
+error.nonnegative-integer-attribute = Attribute "{0}" must be a nonnegative integer value.
+
warning.use-form-bean-on-readonly-action = \
This action has the {0} attribute set to true, but the {1} attribute may cause the value of member field {2} \
to be modified.
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java Mon Feb 14 17:11:54 2005
@@ -61,9 +61,10 @@
{
MergedControllerAnnotation mca = strutsApp.getFlowControllerInfo().getMergedControllerAnnotation();
_strutsApp = strutsApp;
+ setValidatorVersion( mca.getValidatorVersion() );
addRulesFromBeans( jclass );
addRulesFromActions( jclass );
- addRulesFromClass( jclass, mca );
+ addRulesFromClass( mca );
String mergeFileName = mca.getValidatorMerge();
_mergeFile = strutsApp.getMergeFile( mergeFileName );
}
@@ -202,7 +203,7 @@
return formBean.getName();
}
- private void addRulesFromClass( ClassDeclaration jclass, MergedControllerAnnotation mca )
+ private void addRulesFromClass( MergedControllerAnnotation mca )
{
Collection< AnnotationMirror > validationBeanAnnotations = mca.getValidatableBeans();
@@ -319,66 +320,50 @@
//
rule.setMessage( CompilerUtils.getString( ruleAnnotation, MESSAGE_ATTR, true ) );
rule.setMessageKey( CompilerUtils.getString( ruleAnnotation, MESSAGE_KEY_ATTR, true ) );
+ rule.setBundle( CompilerUtils.getString( ruleAnnotation, BUNDLE_NAME_ATTR, true ) );
if ( rule.getMessage() != null ) assert rule.getMessageKey() == null; // TODO: checker should enforce
//
- // arg0
+ // args
//
- String arg0 = CompilerUtils.getString( ruleAnnotation, ARG0_ATTR, true );
- if ( arg0 != null )
- {
- rule.setArg0( arg0, false );
- }
- else
- {
- String arg0Key = CompilerUtils.getString( ruleAnnotation, ARG0_KEY_ATTR, true );
- if ( arg0Key != null ) rule.setArg0( arg0Key, true );
- }
-
- //
- // arg1
- //
- String arg1 = CompilerUtils.getString( ruleAnnotation, ARG1_ATTR, true );
- if ( arg1 != null )
- {
- rule.setArg1( arg1, false );
- }
- else
- {
- String arg1Key = CompilerUtils.getString( ruleAnnotation, ARG1_KEY_ATTR, true );
- if ( arg1Key != null ) rule.setArg1( arg1Key, true );
- }
-
- //
- // arg2
- //
- String arg2 = CompilerUtils.getString( ruleAnnotation, ARG2_ATTR, true );
- if ( arg2 != null )
- {
- rule.setArg2( arg2, false );
- }
- else
- {
- String arg2Key = CompilerUtils.getString( ruleAnnotation, ARG2_KEY_ATTR, true );
- if ( arg2Key != null ) rule.setArg2( arg2Key, true );
- }
-
- //
- // arg3
- //
- String arg3 = CompilerUtils.getString( ruleAnnotation, ARG3_ATTR, true );
- if ( arg3 != null )
- {
- rule.setArg3( arg3, false );
- }
- else
- {
- String arg3Key = CompilerUtils.getString( ruleAnnotation, ARG3_KEY_ATTR, true );
- if ( arg3Key != null ) rule.setArg3( arg3Key, true );
- }
+ addMessageArgs( rule, ruleAnnotation );
}
return rule;
+ }
+
+ protected void addMessageArgs( ValidatorRule rule, AnnotationMirror annotation )
+ {
+ List< AnnotationMirror > messageArgs =
+ CompilerUtils.getAnnotationArray( annotation, MESSAGE_ARGS_ATTR, true );
+
+ if ( messageArgs != null )
+ {
+ int inferredPosition = 0;
+ for ( AnnotationMirror ann : messageArgs )
+ {
+ String arg = CompilerUtils.getString( ann, ARG_ATTR, true );
+ String bundle = CompilerUtils.getString( ann, BUNDLE_NAME_ATTR, true );
+ Integer position = CompilerUtils.getInteger( ann, POSITION_ATTR, true );
+
+ if ( position == null )
+ {
+ position = new Integer( inferredPosition );
+ }
+
+ if ( arg != null )
+ {
+ rule.setArg( arg, false, bundle, position );
+ }
+ else
+ {
+ String argKey = CompilerUtils.getString( ann, ARG_KEY_ATTR, true );
+ if ( argKey != null ) rule.setArg( argKey, true, bundle, position );
+ }
+
+ inferredPosition++;
+ }
+ }
}
protected String getHeaderComment( File mergeFile )
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java Mon Feb 14 17:11:54 2005
@@ -24,57 +24,52 @@
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.type.PrimitiveType;
import static org.apache.beehive.netui.compiler.JpfLanguageConstants.VERSION_9_0_STRING;
import static org.apache.beehive.netui.compiler.JpfLanguageConstants.MESSAGE_KEY_ATTR;
import static org.apache.beehive.netui.compiler.JpfLanguageConstants.MESSAGE_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG0_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG0_KEY_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG1_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG1_KEY_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG2_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG2_KEY_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG3_ATTR;
-import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG3_KEY_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.BUNDLE_NAME_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.MESSAGE_ARGS_ATTR;
import static org.apache.beehive.netui.compiler.JpfLanguageConstants.DISPLAY_NAME_ATTR;
-import java.util.List;
-
public class BaseValidationRuleGrammar
extends AnnotationGrammar
{
private static final String[][] MUTUALLY_EXCLUSIVE_ATTRS =
{
- { MESSAGE_KEY_ATTR, MESSAGE_ATTR },
- { ARG0_KEY_ATTR, ARG0_ATTR },
- { ARG1_KEY_ATTR, ARG1_ATTR },
- { ARG2_KEY_ATTR, ARG2_ATTR },
- { ARG3_KEY_ATTR, ARG3_ATTR },
- { ARG0_KEY_ATTR, MESSAGE_ATTR },
- { ARG1_KEY_ATTR, MESSAGE_ATTR },
- { ARG2_KEY_ATTR, MESSAGE_ATTR },
- { ARG3_KEY_ATTR, MESSAGE_ATTR },
+ { MESSAGE_KEY_ATTR, MESSAGE_ATTR }
};
-
+ private static final String[][] ATTR_DEPENDENCIES =
+ {
+ { BUNDLE_NAME_ATTR, MESSAGE_KEY_ATTR }
+ };
+
+
public BaseValidationRuleGrammar( AnnotationProcessorEnvironment env, Diagnostics diags,
- RuntimeVersionChecker runtimeVersionChecker )
+ RuntimeVersionChecker rvc )
{
- super( env, diags, VERSION_9_0_STRING, runtimeVersionChecker );
-
+ super( env, diags, VERSION_9_0_STRING, rvc );
+
addMemberType( MESSAGE_KEY_ATTR, new MessageKeyType( null, this ) );
+ addMemberArrayGrammar( MESSAGE_ARGS_ATTR, new ValidationMessageArgsGrammar( env, diags, rvc ) );
}
+ @Override
public String[][] getMutuallyExclusiveAttrs()
{
return MUTUALLY_EXCLUSIVE_ATTRS;
}
- protected boolean onBeginCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations,
+ @Override
+ public String[][] getAttrDependencies()
+ {
+ return ATTR_DEPENDENCIES;
+ }
+
+ @Override
+ protected boolean onBeginCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations,
MemberDeclaration classMember )
{
//
@@ -86,8 +81,6 @@
AnnotationMirror immediateParent = parentAnnotations[parentAnnotations.length - 1];
if ( CompilerUtils.getString( immediateParent, DISPLAY_NAME_ATTR, true ) == null
- && CompilerUtils.getString( annotation, ARG0_ATTR, true ) == null
- && CompilerUtils.getString( annotation, ARG0_KEY_ATTR, true ) == null
&& CompilerUtils.getString( annotation, MESSAGE_KEY_ATTR, true ) == null
&& CompilerUtils.getString( annotation, MESSAGE_ATTR, true ) == null )
{
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java Mon Feb 14 17:11:54 2005
@@ -22,7 +22,7 @@
import org.apache.beehive.netui.compiler.FlowControllerInfo;
import org.apache.beehive.netui.compiler.Diagnostics;
import org.apache.beehive.netui.compiler.model.schema.struts11.StrutsConfigDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormValidationDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormValidationDocument;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import static org.apache.beehive.netui.compiler.JpfLanguageConstants.*;
@@ -40,6 +40,7 @@
addMemberType( ROLES_ALLOWED_ATTR, new RolesAllowedType( this ) );
addMemberType( READONLY_ATTR, new AnnotationMemberType( null, this ) );
addMemberType( STRUTSMERGE_ATTR, new ValidXmlFileType( StrutsConfigDocument.type, null, this, fcInfo ) );
+ addMemberType( VALIDATOR_VERSION_ATTR, new AnnotationMemberType( null, this ) );
addMemberType( VALIDATOR_MERGE_ATTR, new ValidXmlFileType( FormValidationDocument.type, null, this, fcInfo ) );
addMemberType( TILES_DEFINITIONS_CONFIGS_ATTR, new TilesDefinitionsConfigsType( null, this, fcInfo ) );
addMemberType( MULTIPART_HANDLER_ATTR, new AnnotationMemberType( null, this ) );
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java Mon Feb 14 17:11:54 2005
@@ -55,7 +55,7 @@
public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value,
AnnotationMirror[] parentAnnotations, MemberDeclaration classMember )
{
- String val = ( String ) value.getValue();
+ String val = value.getValue().toString();
if ( ! _allowEmptyString && val.length() == 0 )
{
Added: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java (added)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java Mon Feb 14 17:11:54 2005
@@ -0,0 +1,104 @@
+/*
+* Copyright 2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* $Header:$
+*/
+package org.apache.beehive.netui.compiler.grammar;
+
+import org.apache.beehive.netui.compiler.AnnotationGrammar;
+import org.apache.beehive.netui.compiler.CompilerUtils;
+import org.apache.beehive.netui.compiler.Diagnostics;
+import org.apache.beehive.netui.compiler.RuntimeVersionChecker;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.MemberDeclaration;
+
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.VERSION_9_0_STRING;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.ARG_KEY_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.BUNDLE_NAME_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.POSITION_ATTR;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.MESSAGE_ARGS_ATTR;
+
+import java.util.Map;
+
+
+public class ValidationMessageArgsGrammar
+ extends AnnotationGrammar
+{
+ private static final String[][] MUTUALLY_EXCLUSIVE_ATTRS =
+ {
+ { ARG_KEY_ATTR, ARG_ATTR }
+ };
+
+ private static final String[][] REQUIRED_ATTRS =
+ {
+ { ARG_KEY_ATTR, ARG_ATTR },
+ };
+
+ private static final String[][] ATTR_DEPENDENCIES =
+ {
+ { BUNDLE_NAME_ATTR, ARG_KEY_ATTR }
+ };
+
+
+ public ValidationMessageArgsGrammar( AnnotationProcessorEnvironment env, Diagnostics diags,
+ RuntimeVersionChecker rvc )
+ {
+ super( env, diags, VERSION_9_0_STRING, rvc );
+
+ // ARG_KEY_ATTR, ARG_ATTR do not need a custom type.
+ addMemberType( POSITION_ATTR, new UniqueValueType( MESSAGE_ARGS_ATTR, false, true, null, this ) );
+ }
+
+ @Override
+ public String[][] getMutuallyExclusiveAttrs()
+ {
+ return MUTUALLY_EXCLUSIVE_ATTRS;
+ }
+
+ @Override
+ public String[][] getRequiredAttrs()
+ {
+ return REQUIRED_ATTRS;
+ }
+
+ @Override
+ public String[][] getAttrDependencies()
+ {
+ return ATTR_DEPENDENCIES;
+ }
+
+ @Override
+ protected Object onEndCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations,
+ MemberDeclaration classMember, Map checkResults )
+ {
+ Integer position = CompilerUtils.getInteger( annotation, POSITION_ATTR, true );
+
+ if ( position == null )
+ {
+ //
+ // Note, GenValidationModel.addMessageArgs() infers the position for
+ // a null position attribute from the postion of the arg in the array.
+ //
+ }
+ else if ( position.intValue() < 0 )
+ {
+ addError( annotation, "error.nonnegative-integer-attribute", POSITION_ATTR );
+ }
+
+ return null;
+ }
+}
Propchange: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidationMessageArgsGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/LocaleSet.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/LocaleSet.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/LocaleSet.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/LocaleSet.java Mon Feb 14 17:11:54 2005
@@ -17,8 +17,8 @@
*/
package org.apache.beehive.netui.compiler.model.validation;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormsetDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormsetDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormDocument;
import java.util.Locale;
import java.util.HashMap;
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableEntity.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableEntity.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableEntity.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableEntity.java Mon Feb 14 17:11:54 2005
@@ -17,8 +17,8 @@
*/
package org.apache.beehive.netui.compiler.model.validation;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FieldDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FieldDocument;
import java.util.HashMap;
import java.util.Map;
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java?view=diff&r1=153877&r2=153878
==============================================================================
--- 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 Mon Feb 14 17:11:54 2005
@@ -17,23 +17,22 @@
*/
package org.apache.beehive.netui.compiler.model.validation;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FieldDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.VarDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.MsgDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.Arg0Document;
+import org.apache.beehive.netui.compiler.model.schema.validator11.ArgDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FieldDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.MsgDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.VarDocument;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import java.lang.reflect.InvocationTargetException;
public class ValidatableField
{
private String _propertyName;
private String _displayName;
private String _displayNameKey;
- private List _rules = new ArrayList();
+ List< ValidatorRule > _rules = new ArrayList< ValidatorRule >();
public ValidatableField( String propertyName, String displayName, String displayNameKey )
@@ -53,9 +52,9 @@
assert rule != null;
String name = rule.getRuleName();
- for ( int i = 0; i < _rules.size(); i++ )
+ for ( ValidatorRule existingRule : _rules )
{
- if ( ( ( ValidatorRule ) _rules.get( i ) ).getRuleName().equals( name ) )
+ if ( existingRule.getRuleName().equals( name ) )
{
return true;
}
@@ -75,29 +74,47 @@
return ( ValidatorRule[] ) _rules.toArray( new ValidatorRule[ _rules.size() ] );
}
- String getDependsList()
+ /**
+ * Merge the rule names with the list in the field element's depends attribute.
+ *
+ * @param fieldElement the XMLBean field element in the validation XML to update
+ */
+ void mergeDependsList( FieldDocument.Field fieldElement )
{
- StringBuffer listStr = new StringBuffer();
-
- for ( int i = 0; i < _rules.size(); i++ )
+ String depends = fieldElement.getDepends();
+ StringBuilder updatedDepends = new StringBuilder();
+
+ if ( depends != null )
{
- if ( i > 0 ) listStr.append( ',' );
- listStr.append( ( ( ValidatorRule ) _rules.get( i ) ).getRuleName() );
+ updatedDepends.append( depends );
+ }
+ else
+ {
+ depends = "";
+ }
+
+ for ( ValidatorRule rule : _rules )
+ {
+ String name = rule.getRuleName();
+ if ( depends.indexOf( name ) == -1 )
+ {
+ if ( updatedDepends.length() > 0 ) updatedDepends.append( ',' );
+ updatedDepends.append( name );
+ }
+ }
+
+ if ( updatedDepends.length() != 0 )
+ {
+ fieldElement.setDepends( updatedDepends.toString() );
}
-
- return listStr.toString();
}
public void writeToXMLBean( FieldDocument.Field fieldElement )
{
assert fieldElement.getProperty().equals( _propertyName );
- if ( fieldElement.getDepends() == null ) {
- String depends = getDependsList();
+ mergeDependsList( fieldElement );
- if ( depends != null && depends.length() > 0 ) { fieldElement.setDepends( depends ); }
- }
-
//
// Add the display name as the default first argument (can be overridden by individual rules).
//
@@ -118,86 +135,26 @@
{
displayName = Character.toUpperCase( _propertyName.charAt( 0 ) ) + _propertyName.substring( 1 );
}
-
- Arg0Document.Arg0[] arg0Array = fieldElement.getArg0Array();
- Arg0Document.Arg0 defaultArg0Element = null;
-
- for ( int i = 0; i < arg0Array.length; i++ )
- {
- Arg0Document.Arg0 arg0 = arg0Array[i];
- if ( arg0.getName() == null ) // not associated with a specific rule -- this is the one we want
- {
- defaultArg0Element = arg0;
- break;
- }
- }
-
- if ( defaultArg0Element == null && _rules.size() > 0 )
- {
- defaultArg0Element = fieldElement.addNewArg0();
- }
-
- if ( defaultArg0Element != null )
- {
- defaultArg0Element.setKey( displayName );
- defaultArg0Element.setResource( Boolean.toString( displayNameIsResource ) );
- }
+ setDefaultArg0Element( displayName, displayNameIsResource, fieldElement );
//
- // Go through the rules, and add each one. Each rule can spray into 1) an entry in the comma-separated
- // rules dependencies list, 2) a set of <var> elements, 3) a set of <argN> elements.
+ // Go through the rules, and add each one. Each rule can spray into...
+ // 1) an entry in the comma-separated rules dependencies list (handled above with mergeDependsList(),
+ // 2) a set of <var> elements,
+ // 3) a set of <arg> elements.
//
- VarDocument.Var[] existingVars = fieldElement.getVarArray();
- for ( int i = 0; i < _rules.size(); i++ )
+ for ( ValidatorRule rule : _rules )
{
- ValidatorRule rule = ( ValidatorRule ) _rules.get( i );
-
//
// Add the message from the rule.
//
- String messageKey = rule.getMessageKey();
- String message = rule.getMessage();
-
- if ( messageKey != null || message != null )
- {
- MsgDocument.Msg[] existingMsgElements = fieldElement.getMsgArray();
- MsgDocument.Msg msgElementToUse = null;
-
- for ( int j = 0; j < existingMsgElements.length; j++ )
- {
- MsgDocument.Msg existingMsgElement = existingMsgElements[j];
- if ( rule.getRuleName().equals( existingMsgElement.getName() ) )
- {
- msgElementToUse = existingMsgElement;
- break;
- }
- }
-
- if ( msgElementToUse == null )
- {
- msgElementToUse = fieldElement.addNewMsg();
- msgElementToUse.setName( rule.getRuleName() );
- }
-
- if ( messageKey != null )
- {
- msgElementToUse.setKey( messageKey );
- msgElementToUse.setResource( Boolean.TRUE.toString() );
- }
- else // message != null (it's a hardcoded message)
- {
- //
- // Add our special constant as the message key, append the hardcoded message to it.
- //
- msgElementToUse.setKey( ValidatorConstants.EXPRESSION_KEY_PREFIX + message );
- msgElementToUse.setResource( Boolean.FALSE.toString() );
- }
- }
-
+ setRuleMessage( rule, fieldElement );
+
//
// Add vars from the rule.
//
+ VarDocument.Var[] existingVars = fieldElement.getVarArray();
Map< String, String > ruleVars = rule.getVars();
if ( ruleVars != null )
@@ -246,70 +203,153 @@
setRuleArg( rule, 3, fieldElement, j != null && j.hasNext() ? j.next() : null );
}
}
-
- void setRuleArg( ValidatorRule rule, int argNum, FieldDocument.Field fieldElement, String altMessageVar )
+
+ /**
+ * Find or create a default arg 0 element not associated with a
+ * specific rule and set it to the display name.
+ */
+ void setDefaultArg0Element( String displayName, boolean displayNameIsResource, FieldDocument.Field fieldElement )
{
- try
+ ArgDocument.Arg[] argArray = fieldElement.getArgArray();
+ ArgDocument.Arg defaultArg0Element = null;
+
+ for ( int i = 0; i < argArray.length; i++ )
{
- Class ruleClass = rule.getClass();
- Class fieldElementClass = fieldElement.getClass();
- ValidatorRule.MessageArg arg =
- ( ValidatorRule.MessageArg ) ruleClass.getMethod( "getArg" + argNum ).invoke( rule );
-
+ ArgDocument.Arg arg = argArray[i];
+ if ( arg.getName() == null && "0".equals( arg.getPosition() ) )
+ {
+ defaultArg0Element = arg;
+ break;
+ }
+ }
+
+ if ( defaultArg0Element == null && _rules.size() > 0 )
+ {
+ defaultArg0Element = fieldElement.addNewArg();
+ defaultArg0Element.setPosition( "0" );
+ }
+
+ if ( defaultArg0Element != null )
+ {
+ defaultArg0Element.setKey( displayName );
+ defaultArg0Element.setResource( Boolean.toString( displayNameIsResource ) );
+ if ( defaultArg0Element.getBundle() != null )
+ {
+ defaultArg0Element.setBundle( null );
+ }
+ }
+ }
+
+ /**
+ * Set up the desired <msg> element and attributes for the given rule.
+ *
+ * @param rule the rule with the message to use
+ * @param fieldElement an XMLBean field element in the validation XML to update
+ */
+ void setRuleMessage( ValidatorRule rule, FieldDocument.Field fieldElement )
+ {
+ String messageKey = rule.getMessageKey();
+ String message = rule.getMessage();
+
+ if ( messageKey != null || message != null )
+ {
+ MsgDocument.Msg[] existingMsgElements = fieldElement.getMsgArray();
+ MsgDocument.Msg msgElementToUse = null;
+
+ for ( int j = 0; j < existingMsgElements.length; j++ )
+ {
+ MsgDocument.Msg existingMsgElement = existingMsgElements[j];
+ if ( rule.getRuleName().equals( existingMsgElement.getName() ) )
+ {
+ msgElementToUse = existingMsgElement;
+ break;
+ }
+ }
+
+ if ( msgElementToUse == null )
+ {
+ msgElementToUse = fieldElement.addNewMsg();
+ msgElementToUse.setName( rule.getRuleName() );
+ }
+
+ if ( messageKey != null )
+ {
+ msgElementToUse.setKey( messageKey );
+ msgElementToUse.setResource( Boolean.TRUE.toString() );
+ String bundle = rule.getBundle();
+ if ( bundle != null && bundle.length() > 0 )
+ {
+ msgElementToUse.setBundle( bundle );
+ }
+ }
+ else // message != null (it's a hardcoded message)
+ {
+ //
+ // Add our special constant as the message key, append the hardcoded message to it.
+ //
+ msgElementToUse.setKey( ValidatorConstants.EXPRESSION_KEY_PREFIX + message );
+ msgElementToUse.setResource( Boolean.FALSE.toString() );
+ }
+ }
+ }
+
+ /**
+ * Set up the desired <arg> element and attributes for the given rule.
+ *
+ * @param rule the rule with the message and arg information to use
+ * @param argNum the position of the arg in the message
+ * @param fieldElement an XMLBean field element in the validation XML to update
+ * @param altMessageVar alternative message var
+ */
+ void setRuleArg( ValidatorRule rule, int argNum, FieldDocument.Field fieldElement, String altMessageVar )
+ {
+ Integer argPosition = new Integer( argNum );
+ String position = argPosition.toString();
+ ValidatorRule.MessageArg arg = rule.getArg( argPosition );
+
String ruleName = rule.getRuleName();
- Object argElementToUse = null;
- Object[] existingArgElements =
- ( Object[] ) fieldElementClass.getMethod( "getArg" + argNum + "Array" ).invoke( fieldElement );
-
- for ( int i = 0; i < existingArgElements.length; i++ )
+ ArgDocument.Arg[] argArray = fieldElement.getArgArray();
+ ArgDocument.Arg argElementToUse = null;
+
+ for ( int i = 0; i < argArray.length; i++ )
{
- Object existingElement = existingArgElements[i];
- if ( ruleName.equals( existingElement.getClass().getMethod( "getName" ).invoke( existingElement ) ) )
+ if ( ruleName.equals( argArray[i].getName() ) && position.equals( argArray[i].getPosition() ) )
{
- argElementToUse = existingElement;
+ argElementToUse = argArray[i];
break;
}
}
-
+
if ( arg != null || altMessageVar != null )
{
if ( argElementToUse == null )
{
- argElementToUse = fieldElementClass.getMethod( "addNewArg" + argNum ).invoke( fieldElement );
+ argElementToUse = fieldElement.addNewArg();
}
- Class argElementToUseClass = argElementToUse.getClass();
-
if ( arg != null )
{
String argMessage = arg.getMessage();
String key = arg.isKey() ? argMessage : ValidatorConstants.EXPRESSION_KEY_PREFIX + argMessage;
- argElementToUseClass.getMethod( "setKey", String.class ).invoke( argElementToUse, key );
+ argElementToUse.setKey( key );
String isResource = Boolean.toString( arg.isKey() );
- argElementToUseClass.getMethod( "setResource", String.class ).invoke( argElementToUse, isResource );
- argElementToUseClass.getMethod( "setName", String.class ).invoke( argElementToUse, ruleName );
+ argElementToUse.setResource( isResource );
+ String bundle = rule.getBundle();
+ if ( arg.isKey() && bundle != null && bundle.length() > 0 )
+ {
+ argElementToUse.setBundle( bundle );
+ }
}
else
{
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 );
+ argElementToUse.setKey( altMessageVar );
+ argElementToUse.setResource( "false" );
}
+
+ argElementToUse.setPosition( position );
+ argElementToUse.setName( ruleName );
}
- }
- catch ( NoSuchMethodException e )
- {
- assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
- }
- catch ( IllegalAccessException e )
- {
- assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
- }
- catch ( InvocationTargetException e )
- {
- assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
- }
}
public String getDisplayName()
Added: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java (added)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java Mon Feb 14 17:11:54 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.compiler.model.validation;
+
+public class ValidatableFieldFactory
+{
+ public static ValidatableField getInstance( String fieldName, String displayName, String displayNameKey,
+ ValidationModel.ValidatorVersion version )
+ {
+ if ( version == ValidationModel.ValidatorVersion.oneOne )
+ {
+ return new ValidatableField( fieldName, displayName, displayNameKey );
+ }
+ else if ( version == ValidationModel.ValidatorVersion.oneZero )
+ {
+ return new ValidatableFieldOld( fieldName, displayName, displayNameKey );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "Unexpected commons-validator version.");
+ }
+ }
+}
Propchange: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java (added)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java Mon Feb 14 17:11:54 2005
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.compiler.model.validation;
+
+import org.apache.beehive.netui.compiler.model.schema.validator11.Arg0Document;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FieldDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.MsgDocument;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class ValidatableFieldOld extends ValidatableField
+{
+ public ValidatableFieldOld( String propertyName, String displayName, String displayNameKey )
+ {
+ super( propertyName, displayName, displayNameKey );
+ }
+
+ //
+ // Support for validator version 1.0 arg0,...,arg3 elements
+ //
+ @Override
+ void setDefaultArg0Element( String displayName, boolean displayNameIsResource, FieldDocument.Field fieldElement )
+ {
+ Arg0Document.Arg0[] arg0Array = fieldElement.getArg0Array();
+ Arg0Document.Arg0 defaultArg0Element = null;
+
+ for ( int i = 0; i < arg0Array.length; i++ )
+ {
+ Arg0Document.Arg0 arg0 = arg0Array[i];
+ if ( arg0.getName() == null )
+ {
+ defaultArg0Element = arg0;
+ break;
+ }
+ }
+
+ if ( defaultArg0Element == null && _rules.size() > 0 )
+ {
+ defaultArg0Element = fieldElement.addNewArg0();
+ }
+
+ if ( defaultArg0Element != null )
+ {
+ defaultArg0Element.setKey( displayName );
+ defaultArg0Element.setResource( Boolean.toString( displayNameIsResource ) );
+ }
+ }
+
+ void setRuleMessage( ValidatorRule rule, FieldDocument.Field fieldElement )
+ {
+ String messageKey = rule.getMessageKey();
+ String message = rule.getMessage();
+
+ if ( messageKey != null || message != null )
+ {
+ MsgDocument.Msg[] existingMsgElements = fieldElement.getMsgArray();
+ MsgDocument.Msg msgElementToUse = null;
+
+ for ( int j = 0; j < existingMsgElements.length; j++ )
+ {
+ MsgDocument.Msg existingMsgElement = existingMsgElements[j];
+ if ( rule.getRuleName().equals( existingMsgElement.getName() ) )
+ {
+ msgElementToUse = existingMsgElement;
+ break;
+ }
+ }
+
+ if ( msgElementToUse == null )
+ {
+ msgElementToUse = fieldElement.addNewMsg();
+ msgElementToUse.setName( rule.getRuleName() );
+ }
+
+ if ( messageKey != null )
+ {
+ msgElementToUse.setKey( messageKey );
+ msgElementToUse.setResource( Boolean.TRUE.toString() );
+ }
+ else // message != null (it's a hardcoded message)
+ {
+ //
+ // Add our special constant as the message key, append the hardcoded message to it.
+ //
+ msgElementToUse.setKey( ValidatorConstants.EXPRESSION_KEY_PREFIX + message );
+ msgElementToUse.setResource( Boolean.FALSE.toString() );
+ }
+ }
+ }
+
+ //
+ // Support for validator version 1.0 and the deprecated <arg0>,...,<arg3> elements,
+ // rather than the general <arg position="N"> element of validator version 1.1.
+ //
+ @Override
+ void setRuleArg( ValidatorRule rule, int argNum, FieldDocument.Field fieldElement, String altMessageVar )
+ {
+ try
+ {
+ Class fieldElementClass = fieldElement.getClass();
+ ValidatorRule.MessageArg arg = rule.getArg( new Integer( argNum ) );
+
+ String ruleName = rule.getRuleName();
+ Object argElementToUse = null;
+ Object[] existingArgElements =
+ ( Object[] ) fieldElementClass.getMethod( "getArg" + argNum + "Array" ).invoke( fieldElement );
+
+ for ( int i = 0; i < existingArgElements.length; i++ )
+ {
+ Object existingElement = existingArgElements[i];
+ if ( ruleName.equals( existingElement.getClass().getMethod( "getName" ).invoke( existingElement ) ) )
+ {
+ argElementToUse = existingElement;
+ break;
+ }
+ }
+
+ if ( arg != null || altMessageVar != null )
+ {
+ if ( argElementToUse == null )
+ {
+ argElementToUse = fieldElementClass.getMethod( "addNewArg" + argNum ).invoke( fieldElement );
+ }
+
+ Class argElementToUseClass = argElementToUse.getClass();
+
+ if ( arg != null )
+ {
+ 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
+ {
+ 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 );
+ }
+ }
+ }
+ catch ( NoSuchMethodException e )
+ {
+ assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
+ }
+ catch ( IllegalAccessException e )
+ {
+ assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
+ }
+ catch ( InvocationTargetException e )
+ {
+ assert false : e; // this shouldn't ever happen -- we know what the compiled types look like.
+ }
+ }
+}
Propchange: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableFieldOld.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java Mon Feb 14 17:11:54 2005
@@ -17,8 +17,8 @@
*/
package org.apache.beehive.netui.compiler.model.validation;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormValidationDocument;
-import org.apache.beehive.netui.compiler.model.schema.struts11.validator.FormsetDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormsetDocument;
+import org.apache.beehive.netui.compiler.model.schema.validator11.FormValidationDocument;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlDocumentProperties;
import org.apache.xmlbeans.XmlCursor;
@@ -35,14 +35,22 @@
import java.util.Collection;
import java.util.Iterator;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.VALIDATOR_VERSION_ONE_ONE_STR;
+
public abstract class ValidationModel
{
private Map _localeSets = new HashMap();
private LocaleSet _defaultLocaleSet = new LocaleSet();
private List _rulesToAddForAllLocales = new ArrayList(); // list of RuleAdd
private boolean _empty = true;
-
-
+ private ValidatorVersion _validatorVersion = ValidatorVersion.oneOne;
+
+ public enum ValidatorVersion
+ {
+ oneZero,
+ oneOne,
+ }
+
public static class RuleInfo
{
private String _entityName;
@@ -78,6 +86,7 @@
return _fieldDisplayNameKey;
}
}
+
private static class RuleAdd
{
public RuleAdd( RuleInfo ruleInfo, ValidatorRule rule )
@@ -89,7 +98,28 @@
public RuleInfo ruleInfo;
public ValidatorRule rule;
}
-
+
+ public ValidatorVersion getValidatorVersion()
+ {
+ return _validatorVersion;
+ }
+
+ public void setValidatorVersion( String validatorVersion )
+ {
+ //
+ // default to the least common denominator (validator v1.0) unless
+ // explicitly set to v1.1.
+ //
+ if ( validatorVersion != null && validatorVersion.equals( VALIDATOR_VERSION_ONE_ONE_STR ) )
+ {
+ _validatorVersion = ValidatorVersion.oneOne;
+ }
+ else
+ {
+ _validatorVersion = ValidatorVersion.oneZero;
+ }
+ }
+
public void addFieldRuleForAllLocales( RuleInfo ruleInfo, ValidatorRule rule )
{
_rulesToAddForAllLocales.add( new RuleAdd( ruleInfo, rule ) );
@@ -159,9 +189,9 @@
ValidatableField field = entity.getField( fieldName );
if ( field == null )
{
- entity.addField( field = new ValidatableField( fieldName,
- ruleInfo.getFieldDisplayName(),
- ruleInfo.getFieldDisplayNameKey() ) );
+ field = ValidatableFieldFactory.getInstance( fieldName, ruleInfo.getFieldDisplayName(),
+ ruleInfo.getFieldDisplayNameKey(), getValidatorVersion() );
+ entity.addField( field );
}
//
@@ -225,12 +255,26 @@
if ( dp.getDoctypePublicId() == null )
{
- dp.setDoctypePublicId( "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" );
+ if ( _validatorVersion == ValidatorVersion.oneZero )
+ {
+ dp.setDoctypePublicId( "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" );
+ }
+ else
+ {
+ dp.setDoctypePublicId( "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN" );
+ }
}
if ( dp.getDoctypeSystemId() == null )
{
- dp.setDoctypeSystemId( "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd" );
+ if ( _validatorVersion == ValidatorVersion.oneZero )
+ {
+ dp.setDoctypeSystemId( "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd" );
+ }
+ else
+ {
+ dp.setDoctypeSystemId( "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd" );
+ }
}
Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatorRule.java?view=diff&r1=153877&r2=153878
==============================================================================
--- 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 Mon Feb 14 17:11:54 2005
@@ -26,21 +26,23 @@
private String _ruleName;
private String _messageKey;
private String _message;
- private MessageArg _arg0;
- private MessageArg _arg1;
- private MessageArg _arg2;
- private MessageArg _arg3;
+ private String _bundle;
+ private Map< Integer, MessageArg > _args;
+
-
public static class MessageArg
{
private String _message;
private boolean _isKey;
+ private String _bundle;
+ private Integer _position;
- public MessageArg( String message, boolean isKey )
+ public MessageArg( String message, boolean isKey, String bundle, Integer position )
{
_message = message;
_isKey = isKey;
+ _bundle = bundle;
+ _position = position;
}
public String getMessage()
@@ -52,6 +54,16 @@
{
return _isKey;
}
+
+ public String getBundle()
+ {
+ return _bundle;
+ }
+
+ public Integer getPosition()
+ {
+ return _position;
+ }
}
public ValidatorRule( String ruleName )
@@ -97,43 +109,25 @@
_message = message;
}
- public MessageArg getArg0()
- {
- return _arg0;
- }
-
- public void setArg0( String message, boolean isKey )
+ public String getBundle()
{
- _arg0 = new MessageArg( message, isKey );
+ return _bundle;
}
- public MessageArg getArg1()
+ public void setBundle( String bundle )
{
- return _arg1;
+ _bundle = bundle;
}
- public void setArg1( String message, boolean isKey )
+ public void setArg( String message, boolean isKey, String bundle, Integer position )
{
- _arg1 = new MessageArg( message, isKey );
- }
-
- public MessageArg getArg2()
- {
- return _arg2;
+ if ( _args == null ) { _args = new LinkedHashMap< Integer, MessageArg >(); }
+ _args.put( position, new MessageArg( message, isKey, bundle, position ) );
}
- public void setArg2( String message, boolean isKey )
- {
- _arg2 = new MessageArg( message, isKey );
- }
-
- public MessageArg getArg3()
- {
- return _arg3;
- }
-
- public void setArg3( String message, boolean isKey )
+ public MessageArg getArg( Integer position )
{
- _arg3 = new MessageArg( message, isKey );
+ if ( _args == null ) { return null; }
+ return _args.get( position );
}
}
Modified: incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/config.xsdconfig
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/config.xsdconfig?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/config.xsdconfig (original)
+++ incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/config.xsdconfig Mon Feb 14 17:11:54 2005
@@ -2,6 +2,6 @@
<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
<xb:namespace>
- <xb:package>org.apache.beehive.netui.compiler.model.schema.struts11.validator</xb:package>
+ <xb:package>org.apache.beehive.netui.compiler.model.schema.validator11</xb:package>
</xb:namespace>
</xb:config>
Modified: incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/struts-validator_1_1.xsd
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/struts-validator_1_1.xsd?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/struts-validator_1_1.xsd (original)
+++ incubator/beehive/trunk/netui/src/compiler/schema/struts-validator/struts-validator_1_1.xsd Mon Feb 14 17:11:54 2005
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="arg">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="key" type="xs:string"/>
+ <xs:attribute name="bundle" type="xs:string"/>
+ <xs:attribute name="position" type="xs:string"/>
+ <xs:attribute name="resource" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
<xs:element name="arg0">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
@@ -42,6 +51,7 @@
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="msg"/>
+ <xs:element ref="arg"/>
<xs:element ref="arg0"/>
<xs:element ref="arg1"/>
<xs:element ref="arg2"/>
@@ -84,7 +94,8 @@
<xs:element name="global">
<xs:complexType>
<xs:sequence>
- <xs:element ref="validator" maxOccurs="unbounded"/>
+ <xs:element ref="validator" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element ref="constant" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -93,6 +104,7 @@
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="key" type="xs:string"/>
+ <xs:attribute name="bundle" type="xs:string"/>
<xs:attribute name="resource" type="xs:string"/>
</xs:complexType>
</xs:element>
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java Mon Feb 14 17:11:54 2005
@@ -47,6 +47,11 @@
String strutsMerge() default "";
/**
+ * The version of the commons-validator DTD to use for our generated validator XML.
+ */
+ ValidatorVersion validatorVersion() default ValidatorVersion.oneZero;
+
+ /**
* Location of the ValidatorPlugIn merge file; relative to the page flow, or a path from the webapp root.
* Optional.
*/
@@ -505,6 +510,25 @@
}
/**
+ * Validation message argument: Arg.
+ */
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
+ public @interface MessageArg
+ {
+ String arg() default "";
+ String argKey() default "";
+ String bundleName() default ""; // optional
+ int position(); // required
+ }
+
+ public enum ValidatorVersion
+ {
+ oneZero,
+ oneOne
+ }
+
+ /**
* Validation rule: Required.
*/
@Target( ANNOTATION_TYPE )
@@ -514,14 +538,8 @@
boolean enabled() default true;
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -535,14 +553,8 @@
int chars(); // required
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -556,14 +568,8 @@
int chars(); // required
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -577,14 +583,8 @@
String regex(); // required
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -598,14 +598,8 @@
Class type();
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -620,14 +614,8 @@
boolean strict() default false;
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -644,14 +632,8 @@
double maxFloat() default -1;
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -664,14 +646,8 @@
boolean enabled() default true;
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -684,14 +660,8 @@
boolean enabled() default true;
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
@@ -705,14 +675,8 @@
String condition(); // required
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
@Target( ANNOTATION_TYPE )
@@ -734,14 +698,8 @@
ValidateCustomVariable[] variables() default {};
String message() default "";
String messageKey() default "";
- String arg0() default "";
- String arg0Key() default "";
- String arg1() default "";
- String arg1Key() default "";
- String arg2() default "";
- String arg2Key() default "";
- String arg3() default "";
- String arg3Key() default "";
+ String bundleName() default "";
+ MessageArg[] messageArgs() default {};
}
/**
Modified: incubator/beehive/trunk/netui/test/webapps/drt/build.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/build.xml?view=diff&r1=153877&r2=153878
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/build.xml (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/build.xml Mon Feb 14 17:11:54 2005
@@ -66,6 +66,8 @@
<echo message="| NetUI coreWeb DRT webapp clean starting |"/>
<echo message="--------------------------------------------------"/>
+ <property name="struts.version" value="1.2"/>
+
<ant antfile="${test.dir}/ant/buildWebapp.xml" target="undeploy.netui" inheritAll="false">
<property name="webapp.dir" location="${webapp.dir}"/>
<property name="struts.version" value="${struts.version}"/>
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java Mon Feb 14 17:11:54 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package validation.messages;
+
+import org.apache.beehive.netui.pageflow.FormData;
+
+
+public class ValidatableFormData extends FormData
+{
+ private String _item1;
+ private String _item2;
+ private String _item3;
+ private String _item4;
+
+ public String getItem1()
+ { return _item1; }
+
+ public void setItem1(String item)
+ { _item1 = item; }
+
+ public String getItem2()
+ { return _item2; }
+
+ public void setItem2(String item)
+ { _item2 = item; }
+
+ public String getItem3()
+ { return _item3; }
+
+ public void setItem3(String item)
+ { _item3 = item; }
+
+ public String getItem4()
+ { return _item4; }
+
+ public void setItem4(String item)
+ { _item4 = item; }
+}
+
Propchange: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/ValidatableFormData.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties Mon Feb 14 17:11:54 2005
@@ -0,0 +1,5 @@
+minlength.msg=Minimum length validation: {0} cannot be less than {1} chars.
+item2.minlength.name=item two
+item2.minlength.length=four
+item4.minlength.name=item four
+item4.minlength.length=eight
Propchange: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties?view=auto&rev=153878
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties Mon Feb 14 17:11:54 2005
@@ -0,0 +1,5 @@
+maxlength.msg=Maximum length validation: {0} cannot be more than {1} chars.
+item2.maxlength.name=item two
+item2.maxlength.length=four
+item4.maxlength.name=item four
+item4.maxlength.length=eight
Propchange: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/validation/messages/moremessages.properties
------------------------------------------------------------------------------
svn:eol-style = native