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/16 18:11:21 UTC

svn commit: r154048 - 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/ test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/ test/webapps/drt/testRecorder/config/ test/webapps/drt/testRecorder/tests/

Author: rich
Date: Wed Feb 16 09:11:15 2005
New Revision: 154048

URL: http://svn.apache.org/viewcvs?view=rev&rev=154048
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-304 : ValidatableProperty annotations not being processed for simple actions

Relatedly, added all the right validation-related warnings (e.g., validation annotations without a validationErrorForward) for simple actions, where they were only added for method actions previously.

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


Added:
    incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/
    incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf   (with props)
    incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp   (with props)
    incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml   (with props)
Modified:
    incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java
    incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.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/ActionGrammar.java
    incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
    incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java
    incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml

Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java?view=diff&r1=154047&r2=154048
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java Wed Feb 16 09:11:15 2005
@@ -406,7 +406,11 @@
             if ( annotationName.equals( ACTION_TAG_NAME ) )
             {
                 _actionGrammar.check( annotation, null, method );
-                checkActionMethod( method, jclass, annotation );
+                
+                if ( ! CompilerUtils.isAssignableFrom( FORWARD_CLASS_NAME, method.getReturnType(), getEnv() ) )
+                {
+                    getDiagnostics().addError( method, "error.method-wrong-return-type", FORWARD_CLASS_NAME );
+                }
             }
             else if ( annotationName.equals( EXCEPTION_HANDLER_TAG_NAME ) )
             {
@@ -419,139 +423,6 @@
     protected void checkInnerClass( ClassDeclaration innerClass )
     {
         _formBeanChecker.check( innerClass, getWebappRoot() );
-    }
-    
-    private void checkActionMethod( MethodDeclaration method, ClassDeclaration jclass, AnnotationMirror annotation )
-    {
-        if ( ! CompilerUtils.isAssignableFrom( FORWARD_CLASS_NAME, method.getReturnType(), getEnv() ) )
-        {
-            getDiagnostics().addError( method, "error.method-wrong-return-type", FORWARD_CLASS_NAME );
-        }
-
-        Collection< ParameterDeclaration > parameters = method.getParameters();
-        int nParameters = parameters.size();
-        TypeDeclaration argTypeDecl = null;
-        
-        if ( nParameters > 0 )
-        {
-            TypeMirror argType = CompilerUtils.getGenericBoundsType( parameters.iterator().next().getType() );
-
-            if ( ! ( argType instanceof DeclaredType ) )
-            {
-                getDiagnostics().addError( method, "error.action-method-invalid-argument-type" );
-                argType = null;
-            }
-            else
-            {
-                argTypeDecl = CompilerUtils.getDeclaration( ( DeclaredType ) argType );
-                
-                if ( argTypeDecl instanceof ClassDeclaration && ! CompilerUtils.hasDefaultConstructor( argTypeDecl ) )
-                {
-                    getDiagnostics().addError( method, "error.action-method-arg-no-default-constructor",
-                                           argTypeDecl.getQualifiedName() );
-                }
-                
-                if ( ! CompilerUtils.hasModifier( argTypeDecl, Modifier.PUBLIC ) )
-                {
-                    getDiagnostics().addError( method, "error.action-method-arg-not-public",
-                                           argTypeDecl.getQualifiedName() );
-                }
-                
-                if ( argTypeDecl.getDeclaringType() != null
-                     && ! CompilerUtils.hasModifier( argTypeDecl, Modifier.STATIC ) )
-                {
-                    getDiagnostics().addError( method, "error.action-method-arg-not-static",
-                                           argTypeDecl.getQualifiedName() );
-                }
-                
-                //
-                // Give a warning if there is no validationErrorForward annotation and doValidation isn't set to false.
-                //
-                if ( CompilerUtils.getAnnotationValue( annotation, VALIDATION_ERROR_FORWARD_ATTR, true ) == null
-                     && hasValidationAnnotations( argTypeDecl ) )
-                {
-                    Boolean doValidation = CompilerUtils.getBoolean( annotation, DO_VALIDATION_ATTR, true );
-                    
-                    if ( doValidation == null || doValidation.booleanValue() )
-                    {
-                        getDiagnostics().addWarning(
-                                method, "warning.validatable-formbean-no-forward",
-                                ANNOTATION_INTERFACE_PREFIX + ACTION_TAG_NAME, VALIDATION_ERROR_FORWARD_ATTR,
-                                VALIDATION_ERROR_FORWARD_ATTR, argTypeDecl.getQualifiedName() );
-                    }
-                }
-            }
-        }
-        
-        _fcInfo.addAction( method.getSimpleName(), argTypeDecl != null ? argTypeDecl.getQualifiedName() : null );
-
-        if ( nParameters > 1 )
-        {
-            getDiagnostics().addError( method, "error.action-method-wrong-arg" );
-        }
-
-        //
-        // Check to make sure the "form" attribute (member variable) matches the form declared as an
-        // argument to the action method.
-        //
-        String formMemberName = CompilerUtils.getStringValue( method, ACTION_TAG_NAME, USE_FORM_BEAN_ATTR, true );
-
-        if ( formMemberName != null )
-        {
-            FieldDeclaration memberForm = CompilerUtils.findField( jclass, formMemberName );
-
-            if ( memberForm != null )
-            {
-                TypeMirror memberFormType = CompilerUtils.getGenericBoundsType( memberForm.getType() );
-                
-                String memberFormTypeName =
-                        memberFormType instanceof DeclaredType
-                        ? CompilerUtils.getDeclaration( ( DeclaredType ) memberFormType ).getQualifiedName()
-                        : memberFormType.toString();
-                
-                if ( nParameters == 0 )
-                {
-                    getDiagnostics().addError( method, "error.action-mismatched-form", USE_FORM_BEAN_ATTR,
-                                               formMemberName, memberFormTypeName );
-                }
-                else
-                {
-                    if ( ! CompilerUtils.isAssignableFrom( argTypeDecl, memberFormType ))
-                    {
-                        getDiagnostics().addError( method, "error.action-mismatched-form", USE_FORM_BEAN_ATTR,
-                                                   formMemberName, memberFormTypeName );
-                    }
-                }
-            }
-        }
-    }
-    
-    private boolean hasValidationAnnotations( TypeDeclaration type )
-    {
-        // Could cache this if it's a performance problem.
-        
-        Collection< ? extends MethodDeclaration > methods = type.getMethods();
-        
-        for ( MethodDeclaration method : methods )
-        {
-            Collection< AnnotationMirror > annotations = method.getAnnotationMirrors();
-            
-            for ( AnnotationMirror ann : annotations )
-            {
-                String annotationName = CompilerUtils.getDeclaration( ann.getAnnotationType() ).getQualifiedName();
-                int pos = annotationName.indexOf( ANNOTATION_QUALIFIER );
-                
-                if ( pos != -1 )
-                {
-                    if ( annotationName.substring( pos + ANNOTATION_QUALIFIER.length() ).startsWith( "Validat" ) )
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-        
-        return false;
     }
     
     private void checkExceptionHandlerMethod( MethodDeclaration method )

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=154047&r2=154048
==============================================================================
--- 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 Wed Feb 16 09:11:15 2005
@@ -27,6 +27,7 @@
     public static final String ANNOTATIONS_CLASSNAME = PAGEFLOW_PACKAGE + ".annotations.Jpf";
     
     public static final String ACTION_TAG_NAME = "Action";
+    public static final String SIMPLE_ACTION_TAG_NAME = "SimpleAction";
     public static final String EXCEPTION_HANDLER_TAG_NAME = "ExceptionHandler";
     public static final String FORWARD_TAG_NAME = "Forward";
     public static final String CATCH_TAG_NAME = "Catch";

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=154047&r2=154048
==============================================================================
--- 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 Wed Feb 16 09:11:15 2005
@@ -29,10 +29,10 @@
 error.file-not-found = File "{0}" could not be found in the web application.
 error.only-valid-in-nested = Attribute "{0}" is only valid in a nested PageFlowController.
 error.action-method-wrong-arg = Expected a single argument.
-error.action-method-arg-no-default-constructor = Argument type {0} has no default constructor defined.
-error.action-method-invalid-argument-type = This type is not valid as the argument to an action method.
-error.action-method-arg-not-public = Argument type {0} is not public.
-error.action-method-arg-not-static = Argument type {0} is a non-static inner class.
+error.action-form-bean-no-default-constructor = Argument type {0} has no default constructor defined.
+error.action-invalid-form-bean-type = This type is not valid as the form bean for an action.
+error.action-form-bean-not-public = Argument type {0} is not public.
+error.action-form-bean-not-static = Argument type {0} is a non-static inner class.
 error.method-wrong-return-type = Expected a return type of {0}.
 error.exception-method-wrong-exception-arg = The first argument must have a type that derives from {0}.
 error.exception-method-wrong-arg-type = Argument {0} must be of type {1}.
@@ -82,13 +82,13 @@
 warning.return-to-action-deprecated = The "{0}" value is deprecated.
 
 error.action-mismatched-form = \
-The "{0}" attribute points to member {1}, which requires that this action method accept an argument of type {2}.
+The {0} attribute points to a member of type {1}, which requires that this action method accept an argument of type {1}.
 
 error.required-runtime-version-enumval = \
-The "{0}" value requires an up-to-date version of {1}.
+The {0} value requires an up-to-date version of {1}.
 
 error.required-runtime-version-attribute = \
-The "{0}" attribute requires an up-to-date version of {1}.
+The {0} attribute requires an up-to-date version of {1}.
 
 error.required-runtime-version-annotation = \
 This annotation requires an up-to-date version of {0}.
@@ -129,11 +129,11 @@
 error.invalid-member-form-type = Member field {0} is not a valid form bean class type.
 
 warning.validation-annotations-no-forward = \
-The {0} annotation does not have a {1} value.  Without a {1}, this validation annotation will have no effect.
+The enclosing {0} annotation does not have a {1} value.  Without a {1}, this validation annotation will have no effect.
 
 warning.validatable-formbean-no-forward = \
-The {0} annotation does not have a {1} value.  Without a {1}, the validation annotations on form bean \
-{2} will have no effect.
+The enclosing {0} annotation does not have a {1} value.  Without a {1}, the validation annotations on the form bean \
+of type {2} will have no effect.
 
 error.validatable-field-property-name-not-allowed = \
 The {0} attribute is not allowed here. The property name is inferred from the getter method name.

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=154047&r2=154048
==============================================================================
--- 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 Wed Feb 16 09:11:15 2005
@@ -167,23 +167,44 @@
         for ( MethodDeclaration method : methods )
         {
             AnnotationMirror actionAnnotation = CompilerUtils.getAnnotation( method, ACTION_TAG_NAME );
-            
             assert actionAnnotation != null;
-            Collection< AnnotationMirror > validationFieldAnnotations =
-                    CompilerUtils.getAnnotationArray( actionAnnotation, VALIDATABLE_PROPERTIES_ATTR, false );
-            String actionPath = "/" + method.getSimpleName();   // Struts validator needs the slash in front
-            
-            for ( AnnotationMirror validationFieldAnnotation : validationFieldAnnotations )
+            addRulesFromActionAnnotation( actionAnnotation, method.getSimpleName() );
+        }
+        
+        
+        AnnotationMirror controllerAnnotation = CompilerUtils.getAnnotation( jclass, CONTROLLER_TAG_NAME );
+        assert controllerAnnotation != null;    // checker should enforce this
+        
+        Collection< AnnotationMirror > simpleActions =
+                CompilerUtils.getAnnotationArray( controllerAnnotation, SIMPLE_ACTIONS_ATTR, true );
+        
+        if ( simpleActions != null )
+        {
+            for ( AnnotationMirror simpleAction : simpleActions )
             {
-                String propertyName = CompilerUtils.getString( validationFieldAnnotation, PROPERTY_NAME_ATTR, true );
-                assert propertyName != null;            // TODO: checker must enforce this
-                assert ! propertyName.equals( "" );     // TODO: checker must enforce this
-                
-                //
-                // Add the rules, and associate them with the action path ("/" + the action name).
-                //
-                addRulesFromAnnotation( validationFieldAnnotation, actionPath, propertyName );
+                String actionName = CompilerUtils.getString( simpleAction, NAME_ATTR, true );
+                assert actionName != null;  //checker should enforce this.
+                addRulesFromActionAnnotation( simpleAction, actionName );
             }
+        }
+    }
+    
+    private void addRulesFromActionAnnotation( AnnotationMirror actionAnnotation, String actionName )
+    {
+        Collection< AnnotationMirror > validatablePropertyAnnotations =
+                CompilerUtils.getAnnotationArray( actionAnnotation, VALIDATABLE_PROPERTIES_ATTR, false );
+        
+        for ( AnnotationMirror validationFieldAnnotation : validatablePropertyAnnotations )
+        {
+            String propertyName = CompilerUtils.getString( validationFieldAnnotation, PROPERTY_NAME_ATTR, true );
+            assert propertyName != null;            // TODO: checker must enforce this
+            assert ! propertyName.equals( "" );     // TODO: checker must enforce this
+            
+            //
+            // Add the rules, and associate them with the action path ("/" + the action name).
+            //
+            String actionPath = '/' + actionName;   // Struts validator needs the slash in front
+            addRulesFromAnnotation( validationFieldAnnotation, actionPath, propertyName );
         }
     }
     

Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java?view=diff&r1=154047&r2=154048
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java Wed Feb 16 09:11:15 2005
@@ -23,15 +23,14 @@
 import org.apache.beehive.netui.compiler.Diagnostics;
 import org.apache.beehive.netui.compiler.CompilerUtils;
 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.FieldDeclaration;
+import com.sun.mirror.declaration.*;
+import com.sun.mirror.type.TypeMirror;
+import com.sun.mirror.type.DeclaredType;
 
 import static org.apache.beehive.netui.compiler.JpfLanguageConstants.*;
 
+import java.util.Collection;
+
 
 public class ActionGrammar
         extends BaseFlowControllerGrammar
@@ -67,9 +66,164 @@
     protected boolean onBeginCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations, 
                                     MemberDeclaration classMember )
     {
+        //
+        // First check the form bean type.
+        //
+        TypeMirror argType = getFormBeanType( annotation, classMember );
+        TypeDeclaration argTypeDecl = null;
+        
+        if ( ! ( argType instanceof DeclaredType ) )
+        {
+            if ( argType != null )
+            {
+                getDiagnostics().addError( annotation, "error.action-invalid-form-bean-type" );
+                argType = null;
+            }
+        }
+        else
+        {
+            argTypeDecl = CompilerUtils.getDeclaration( ( DeclaredType ) argType );
+            
+            if ( argTypeDecl instanceof ClassDeclaration && ! CompilerUtils.hasDefaultConstructor( argTypeDecl ) )
+            {
+                getDiagnostics().addError( annotation, "error.action-form-bean-no-default-constructor",
+                                           argTypeDecl.getQualifiedName() );
+            }
+            
+            if ( ! CompilerUtils.hasModifier( argTypeDecl, Modifier.PUBLIC ) )
+            {
+                getDiagnostics().addError( annotation, "error.action-form-bean-not-public",
+                                           argTypeDecl.getQualifiedName() );
+            }
+            
+            if ( argTypeDecl.getDeclaringType() != null
+                 && ! CompilerUtils.hasModifier( argTypeDecl, Modifier.STATIC ) )
+            {
+                getDiagnostics().addError( annotation, "error.action-form-bean-not-static",
+                                           argTypeDecl.getQualifiedName() );
+            }
+            
+            //
+            // Give a warning if there is no validationErrorForward annotation and doValidation isn't set to false.
+            //
+            if ( CompilerUtils.getAnnotationValue( annotation, VALIDATION_ERROR_FORWARD_ATTR, true ) == null
+                 && hasValidationAnnotations( argTypeDecl ) )
+            {
+                Boolean doValidation = CompilerUtils.getBoolean( annotation, DO_VALIDATION_ATTR, true );
+                
+                if ( doValidation == null || doValidation.booleanValue() )
+                {
+                    getDiagnostics().addWarning(
+                            annotation, "warning.validatable-formbean-no-forward",
+                            ANNOTATION_INTERFACE_PREFIX + annotation.getAnnotationType().getDeclaration().getSimpleName(),
+                            VALIDATION_ERROR_FORWARD_ATTR, argTypeDecl.getQualifiedName() );
+                }
+            }
+        }
+        
+        //
+        // Add this action to the FlowControllerInfo.
+        //
+        getFlowControllerInfo().addAction( getActionName( annotation, classMember ),
+                                           argTypeDecl != null ? argTypeDecl.getQualifiedName() : null );
+
+        //
+        // Check to make sure the 'useFormBean' attribute (reference to a member variable) matches the form declared as
+        // an argument to the action method.
+        //
+        TypeMirror useFormBeanType = getUseFormBeanType( annotation, classMember );
+        
+        if ( useFormBeanType != null && useFormBeanType instanceof DeclaredType )
+        {
+            if ( argType == null )
+            {
+                String memberFormTypeName = CompilerUtils.getDeclaration( ( DeclaredType ) useFormBeanType ).getQualifiedName();
+                getDiagnostics().addError( annotation, "error.action-mismatched-form", USE_FORM_BEAN_ATTR,
+                                           memberFormTypeName );
+            }
+            else if ( ! CompilerUtils.isAssignableFrom( argTypeDecl, useFormBeanType ))
+            {
+                String memberFormTypeName = CompilerUtils.getDeclaration( ( DeclaredType ) useFormBeanType ).getQualifiedName();
+                getDiagnostics().addError( annotation, "error.action-mismatched-form", USE_FORM_BEAN_ATTR,
+                                           memberFormTypeName );
+            }
+        }
+        
         return true;
     }
 
+    protected String getActionName( AnnotationMirror annotation, MemberDeclaration classMember )
+    {
+        assert classMember instanceof MethodDeclaration : classMember.getClass().getName();
+        return classMember.getSimpleName();
+    }
+    
+    private static boolean hasValidationAnnotations( TypeDeclaration type )
+    {
+        // Could cache this if it's a performance problem.
+        
+        Collection< ? extends MethodDeclaration > methods = type.getMethods();
+        
+        for ( MethodDeclaration method : methods )
+        {
+            Collection< AnnotationMirror > annotations = method.getAnnotationMirrors();
+            
+            for ( AnnotationMirror ann : annotations )
+            {
+                String annotationName = CompilerUtils.getDeclaration( ann.getAnnotationType() ).getQualifiedName();
+                int pos = annotationName.indexOf( ANNOTATION_QUALIFIER );
+                
+                if ( pos != -1 )
+                {
+                    if ( annotationName.substring( pos + ANNOTATION_QUALIFIER.length() ).startsWith( "Validat" ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+        
+        return false;
+    }
+    
+    protected TypeMirror getUseFormBeanType( AnnotationMirror annotation, MemberDeclaration classMember )
+    {
+        String formBeanFieldName = CompilerUtils.getString( annotation, USE_FORM_BEAN_ATTR, true );
+        
+        if ( formBeanFieldName != null )
+        {
+            FieldDeclaration formBeanField =
+                    CompilerUtils.findField( CompilerUtils.getOutermostClass( classMember ), formBeanFieldName );
+            
+            if ( formBeanField != null )
+            {
+                return CompilerUtils.getGenericBoundsType( formBeanField.getType() );
+            }
+        }
+        
+        return null;
+    }
+    
+    protected TypeMirror getFormBeanType( AnnotationMirror annotation, MemberDeclaration classMember )
+    {
+        assert classMember instanceof MethodDeclaration : classMember.getClass().getName();
+        MethodDeclaration method = ( MethodDeclaration ) classMember;
+        Collection< ParameterDeclaration > parameters = method.getParameters();
+        int nParameters = parameters.size();
+        
+        if ( nParameters > 1 )
+        {
+            getDiagnostics().addError( method, "error.action-method-wrong-arg" );
+        }
+        
+        if ( nParameters > 0 )
+        {
+            return CompilerUtils.getGenericBoundsType( parameters.iterator().next().getType() );
+        }
+        
+        return null;
+    }
+    
     private class DoValidateType
         extends AnnotationMemberType
     {

Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java?view=diff&r1=154047&r2=154048
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java Wed Feb 16 09:11:15 2005
@@ -28,6 +28,8 @@
 import com.sun.mirror.declaration.TypeDeclaration;
 import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
 import com.sun.mirror.declaration.AnnotationValue;
+import com.sun.mirror.declaration.FieldDeclaration;
+import com.sun.mirror.type.TypeMirror;
 
 import static org.apache.beehive.netui.compiler.JpfLanguageConstants.*;
 
@@ -79,7 +81,18 @@
         //
         _forwardGrammar.check( annotation, parentAnnotations, classMember );
         
-        return true;
+        return super.onBeginCheck( annotation, parentAnnotations, classMember );
+    }
+    
+    protected String getActionName( AnnotationMirror annotation, MemberDeclaration classMember )
+    {
+        return CompilerUtils.getString( annotation, NAME_ATTR, false );
+    }
+    
+    protected TypeMirror getFormBeanType( AnnotationMirror annotation, MemberDeclaration classMember )
+    {
+        // for a SimpleAction, the form bean type is wholly defined by the useFormBean attribute.
+        return getUseFormBeanType( annotation, classMember );
     }
     
     private static class SimpleActionForwardGrammar

Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java?view=diff&r1=154047&r2=154048
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java (original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java Wed Feb 16 09:11:15 2005
@@ -22,7 +22,6 @@
 import com.sun.mirror.declaration.MemberDeclaration;
 import org.apache.beehive.netui.compiler.RuntimeVersionChecker;
 import org.apache.beehive.netui.compiler.AnnotationMemberType;
-import org.apache.beehive.netui.compiler.AnnotationGrammar;
 import org.apache.beehive.netui.compiler.Diagnostics;
 import org.apache.beehive.netui.compiler.CompilerUtils;
 
@@ -63,21 +62,32 @@
     protected boolean onBeginCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations,
                                     MemberDeclaration classMember )
     {
-        AnnotationMirror actionAnnotation = CompilerUtils.getAnnotation( classMember, ACTION_TAG_NAME );
+        if ( parentAnnotations == null ) return true;
         
-        if ( actionAnnotation != null )     // if it's null, we're in the Controller annotation -- no checks for that
+        //
+        // Look through all annotation parents for @Jpf.Action or @Jpf.SimpleAction.  If we find one, and there's
+        // no validationErrorForward on it, print a warning.
+        //
+        for ( int i = parentAnnotations.length - 1; i >= 0; --i )
         {
-            //
-            // Give a warning if there is no validationErrorForward annotation and doValidation isn't set to false.
-            //
-            if ( CompilerUtils.getAnnotationValue( actionAnnotation, VALIDATION_ERROR_FORWARD_ATTR, true ) == null )
+            AnnotationMirror ann = parentAnnotations[i];
+            
+            if ( CompilerUtils.isJpfAnnotation( ann, ACTION_TAG_NAME )
+                 || CompilerUtils.isJpfAnnotation( ann, SIMPLE_ACTION_TAG_NAME ) )
             {
-                Boolean doValidation = CompilerUtils.getBoolean( actionAnnotation, DO_VALIDATION_ATTR, true );
-                
-                if ( doValidation == null || doValidation.booleanValue() )
+                //
+                // Give a warning if there is no validationErrorForward annotation and doValidation isn't set to false.
+                //
+                if ( CompilerUtils.getAnnotationValue( ann, VALIDATION_ERROR_FORWARD_ATTR, true ) == null )
                 {
-                    addWarning( annotation, "warning.validation-annotations-no-forward",
-                                ANNOTATION_INTERFACE_PREFIX + ACTION_TAG_NAME, VALIDATION_ERROR_FORWARD_ATTR );
+                    Boolean doValidation = CompilerUtils.getBoolean( ann, DO_VALIDATION_ATTR, true );
+                    
+                    if ( doValidation == null || doValidation.booleanValue() )
+                    {
+                        addWarning( annotation, "warning.validation-annotations-no-forward",
+                                    ANNOTATION_INTERFACE_PREFIX + ann.getAnnotationType().getDeclaration().getSimpleName(), 
+                                    VALIDATION_ERROR_FORWARD_ATTR );
+                    }
                 }
             }
         }
@@ -85,4 +95,3 @@
         return true;
     }
 }
-

Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf?view=auto&rev=154048
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf Wed Feb 16 09:11:15 2005
@@ -0,0 +1,42 @@
+package validation.simpleActionDeclarativeValidation;
+
+import org.apache.beehive.netui.pageflow.*;
+import org.apache.beehive.netui.pageflow.annotations.*;
+
+@Jpf.Controller(
+    simpleActions={
+        @Jpf.SimpleAction(name="begin", path="index.jsp"),
+        @Jpf.SimpleAction(
+            name="submit",
+            path="index.jsp",
+            useFormBean="_form",
+            validationErrorForward=@Jpf.Forward(name="failure", path="index.jsp"),
+            validatableProperties={
+                @Jpf.ValidatableProperty(
+                    displayName="Bar",
+                    propertyName="bar",
+                    validateRequired=@Jpf.ValidateRequired()
+                )
+            }
+        )
+    }
+)
+public class Controller extends PageFlowController
+{
+    private MyForm _form;
+
+    public static class MyForm implements java.io.Serializable
+    {
+        private String _bar;
+
+        public String getBar()
+        {
+            return _bar;
+        }
+
+        public void setBar( String bar )
+        {
+            _bar = bar;
+        }
+    }
+}

Propchange: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp?view=auto&rev=154048
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp Wed Feb 16 09:11:15 2005
@@ -0,0 +1,18 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+<%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%>
+
+<netui:html>
+    <head>
+        <netui:base/>
+    </head>
+    <netui:body>
+        <h3>${pageFlow.URI}</h3>
+
+        <netui:form action="submit">
+            bar: <netui:textBox dataSource="actionForm.bar"/> <netui:errors/>
+            <br/>
+            <netui:button value="submit"/>
+        </netui:form>
+    </netui:body>
+</netui:html>

Propchange: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&r1=154047&r2=154048
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Wed Feb 16 09:11:15 2005
@@ -6059,6 +6059,19 @@
          </features>
       </test>
       <test>
+         <name>SimpleActionDeclarativeValidation</name>
+         <description>Test of declarative validation annotations on Simple Actions.</description>
+         <webapp>coreWeb</webapp>
+         <categories>
+            <category>bvt</category>
+            <category>bvt.struts11</category>
+         </categories>
+         <features>
+            <feature>Action</feature>
+            <feature>Validation</feature>
+         </features>
+      </test>
+      <test>
          <name>SimpleExpressionTest</name>
          <description>SimpleExpressionTest</description>
          <webapp>coreWeb</webapp>

Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml?view=auto&rev=154048
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml Wed Feb 16 09:11:15 2005
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
+   <ses:sessionName>SimpleActionDeclarativeValidation</ses:sessionName>
+   <ses:tester>rich</ses:tester>
+   <ses:startDate>15 Feb 2005, 06:31:49.912 PM MST</ses:startDate>
+   <ses:description>Test of declarative validation annotations on Simple Actions.</ses:description>
+   <ses:tests>
+      <ses:test>
+         <ses:testNumber>1</ses:testNumber>
+         <ses:request>
+            <ses:protocol>HTTP</ses:protocol>
+            <ses:protocolVersion>1.1</ses:protocolVersion>
+            <ses:host>localhost</ses:host>
+            <ses:port>8080</ses:port>
+            <ses:uri>/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf</ses:uri>
+            <ses:method>GET</ses:method>
+            <ses:parameters/>
+            <ses:cookies>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>B98603F3E76EAB74F427BA6A14EC1923</ses:value>
+               </ses:cookie>
+            </ses:cookies>
+            <ses:headers>
+               <ses:header>
+                  <ses:name>accept</ses:name>
+                  <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-charset</ses:name>
+                  <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-encoding</ses:name>
+                  <ses:value>gzip,deflate</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-language</ses:name>
+                  <ses:value>en-us,en;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>connection</ses:name>
+                  <ses:value>keep-alive</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>cookie</ses:name>
+                  <ses:value>JSESSIONID=B98603F3E76EAB74F427BA6A14EC1923</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>host</ses:name>
+                  <ses:value>localhost:8080</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>keep-alive</ses:name>
+                  <ses:value>300</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>user-agent</ses:name>
+                  <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value>
+               </ses:header>
+            </ses:headers>
+         </ses:request>
+         <ses:response>
+            <ses:statusCode>200</ses:statusCode>
+            <ses:reason/>
+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+
+    <head>
+        <base href="http://localhost:8080/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp">
+    </head>
+    <body>
+        <h3>/validation/simpleActionDeclarativeValidation/Controller.jpf</h3>
+
+        <form action="/coreWeb/validation/simpleActionDeclarativeValidation/submit.do" method="post">
+            bar: <input type="text" name="{actionForm.bar}"> 
+            <br/>
+            <input type="submit" value="submit">
+        </form>
+    </body>
+
+</html>]]></ses:responseBody>
+         </ses:response>
+      </ses:test>
+      <ses:test>
+         <ses:testNumber>2</ses:testNumber>
+         <ses:request>
+            <ses:protocol>HTTP</ses:protocol>
+            <ses:protocolVersion>1.1</ses:protocolVersion>
+            <ses:host>localhost</ses:host>
+            <ses:port>8080</ses:port>
+            <ses:uri>/coreWeb/validation/simpleActionDeclarativeValidation/submit.do</ses:uri>
+            <ses:method>POST</ses:method>
+            <ses:parameters>
+               <ses:parameter>
+                  <ses:name>{actionForm.bar}</ses:name>
+                  <ses:value/>
+               </ses:parameter>
+            </ses:parameters>
+            <ses:cookies>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>B98603F3E76EAB74F427BA6A14EC1923</ses:value>
+               </ses:cookie>
+            </ses:cookies>
+            <ses:headers>
+               <ses:header>
+                  <ses:name>accept</ses:name>
+                  <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-charset</ses:name>
+                  <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-encoding</ses:name>
+                  <ses:value>gzip,deflate</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-language</ses:name>
+                  <ses:value>en-us,en;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>connection</ses:name>
+                  <ses:value>keep-alive</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>content-length</ses:name>
+                  <ses:value>21</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>content-type</ses:name>
+                  <ses:value>application/x-www-form-urlencoded</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>cookie</ses:name>
+                  <ses:value>JSESSIONID=B98603F3E76EAB74F427BA6A14EC1923</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>host</ses:name>
+                  <ses:value>localhost:8080</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>keep-alive</ses:name>
+                  <ses:value>300</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>referer</ses:name>
+                  <ses:value>http://localhost:8080/coreWeb/validation/simpleActionDeclarativeValidation/Controller.jpf</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>user-agent</ses:name>
+                  <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value>
+               </ses:header>
+            </ses:headers>
+         </ses:request>
+         <ses:response>
+            <ses:statusCode>200</ses:statusCode>
+            <ses:reason/>
+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+	"http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+
+    <head>
+        <base href="http://localhost:8080/coreWeb/validation/simpleActionDeclarativeValidation/index.jsp">
+    </head>
+    <body>
+        <h3>/validation/simpleActionDeclarativeValidation/Controller.jpf</h3>
+
+        <form action="/coreWeb/validation/simpleActionDeclarativeValidation/submit.do" method="post">
+            bar: <input type="text" name="{actionForm.bar}"> Bar is required.
+
+            <br/>
+            <input type="submit" value="submit">
+        </form>
+    </body>
+
+</html>]]></ses:responseBody>
+         </ses:response>
+      </ses:test>
+   </ses:tests>
+   <ses:endDate>15 Feb 2005, 06:31:55.450 PM MST</ses:endDate>
+   <ses:testCount>2</ses:testCount>
+</ses:recorderSession>

Propchange: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/SimpleActionDeclarativeValidation.xml
------------------------------------------------------------------------------
    svn:eol-style = native