diff options
author | itrimble | 2011-11-01 21:10:36 +0000 |
---|---|---|
committer | itrimble | 2011-11-01 21:10:36 +0000 |
commit | 3d0cd63db5e62bfe829910eb6864dc13a6fbcf43 (patch) | |
tree | 8477b2a2561d0444bd326c0f78bedb34fc22eb70 | |
parent | f8e914291b33a3039e3c0faa22ac19a315b42909 (diff) | |
download | webtools.jsf-3d0cd63db5e62bfe829910eb6864dc13a6fbcf43.tar.gz webtools.jsf-3d0cd63db5e62bfe829910eb6864dc13a6fbcf43.tar.xz webtools.jsf-3d0cd63db5e62bfe829910eb6864dc13a6fbcf43.zip |
Bug 333666 - [JSF2.0] AppConfig validator does not support custom bean scope
4 files changed, 39 insertions, 6 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java index a99dd2aee..46cfd17c0 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java @@ -280,13 +280,25 @@ public final class AppConfigValidationUtil */ public static IMessage validateManagedBeanScope(ManagedBeanScopeType scope, IFile file, JSFVersion version) { + final String textContent = scope.getTextContent(); // scope must be one of a few enums - if (!"request".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"session".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"application".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"none".equals(scope.getTextContent())//$NON-NLS-1$ - && ((version == null) || !((version.compareTo(JSFVersion.V2_0) >=0) && "view".equals(scope.getTextContent()) ))) //$NON-NLS-1$ + if (!"request".equals(textContent) //$NON-NLS-1$ + && !"session".equals(textContent) //$NON-NLS-1$ + && !"application".equals(textContent) //$NON-NLS-1$ + && !"none".equals(textContent)//$NON-NLS-1$ + && ((version == null) || !((version.compareTo(JSFVersion.V2_0) >=0) && "view".equals(textContent)))) //$NON-NLS-1$ { + //if JSF version >= 2.0, scope may be EL pointing at a Map instance + if (version != null && version.compareTo(JSFVersion.V2_0) >=0) { + final String elRegex = "#\\{(.*)\\}"; //$NON-NLS-1$ + final Pattern pattern = Pattern.compile(elRegex); + final Matcher matcher = pattern.matcher(textContent.trim()); + if (matcher.matches()) { + //scope is EL, validate it + return validateELExpression(textContent); + } + return DiagnosticFactory.create_BEAN_SCOPE_NOT_VALID_JSF2(); + } return DiagnosticFactory.create_BEAN_SCOPE_NOT_VALID(); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java index 219bd5976..e1d70d504 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java @@ -112,6 +112,11 @@ public final class DiagnosticFactory public final static int LOCALE_FORMAT_NOT_VALID_ID = 16; /** + * Problem id + */ + public final static int BEAN_SCOPE_NOT_VALID_JSF2_ID = 17; + + /** * @return message indicating text that should be EL was * not found sorrounded in #{} values */ @@ -232,7 +237,7 @@ public final class DiagnosticFactory } /** - * @return an error indicating an invalid bean scope enum value + * @return an error indicating an invalid bean scope enum value (pre-JSF2) */ public static IMessage create_BEAN_SCOPE_NOT_VALID() { @@ -242,6 +247,16 @@ public final class DiagnosticFactory } /** + * @return an error indicating an invalid bean scope enum value (JSF2+) + */ + public static IMessage create_BEAN_SCOPE_NOT_VALID_JSF2() + { + return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, + Messages.BEAN_SCOPE_NOT_VALID_JSF2_ID + , null, BEAN_SCOPE_NOT_VALID_JSF2_ID); + } + + /** * @param targetName * @return an error indicating that a map entry is being set on a target * object that is not a java.util.Map diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java index b0535a9a5..146a16364 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java @@ -81,6 +81,11 @@ class Messages extends NLS { /** * see messages.properties */ + public static String BEAN_SCOPE_NOT_VALID_JSF2_ID; + + /** + * see messages.properties + */ public static String MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID; /** diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties index b910ba6e6..28567942d 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties @@ -18,6 +18,7 @@ API_DEPRECATED_AFTER_VERSION_ID=API {0} is deprecated after JSF {1}. Use {2} in BEAN_PROPERTY_NOT_FOUND_ID=Bean property {0} not found on parent class {1} MUST_BE_A_VALID_JAVA_IDENT_ID={0} must be a valid Java identifier BEAN_SCOPE_NOT_VALID_ID=Managed bean scope must be one of: request, session, application, none +BEAN_SCOPE_NOT_VALID_JSF2_ID=Managed bean scope must be one of: view, request, session, application, none MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID=Map entries can only be set on objects of type Map. {0} is not an instance of type java.util.Map LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID=List entries can only be set on objects of type List. {0} is not an instance of type java.util.List API_NOT_AVAILABLE_BEFORE_VERSION_ID=API {0} is not avaiable before JSF {1}. Use {2} instead. |