in ti/phase2/jars/core/src/java/org/apache/ti/compiler/internal/grammar/ActionGrammar.java [71:145]
protected boolean onBeginCheck(AnnotationInstance annotation, AnnotationInstance[] parentAnnotations,
MemberDeclaration classMember)
throws FatalCompileTimeException {
//
// First check the form bean type.
//
TypeInstance argType = getFormBeanType(annotation, classMember);
TypeDeclaration argTypeDecl = null;
if (! (argType instanceof DeclaredType)) {
if (argType != null) {
getDiagnostics().addError(annotation, "error.action-invalid-form-bean-type", argType.toString());
argType = null;
}
} else {
argTypeDecl = CompilerUtils.getDeclaration((DeclaredType) argType);
boolean isClass = argTypeDecl instanceof ClassDeclaration;
if (isClass && ! CompilerUtils.hasDefaultConstructor(argTypeDecl)) {
getDiagnostics().addError(annotation, "error.action-form-bean-no-default-constructor",
argTypeDecl.getQualifiedName());
}
if (! argTypeDecl.hasModifier(Modifier.PUBLIC)) {
getDiagnostics().addError(annotation, "error.action-form-bean-not-public",
argTypeDecl.getQualifiedName());
}
if (isClass && argTypeDecl.getDeclaringType() != null && ! argTypeDecl.hasModifier(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.
//
TypeInstance 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;
}