Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsrinivasan2012-05-14 18:49:11 -0400
committerrsrinivasan2012-05-14 18:49:11 -0400
commitbba4d5731f6b6528025d2084030216704e73adf2 (patch)
treee9805e324ce2207d4cdd4adbbccb2ddbff168113
parent339563a977b28e46001a7fdc32468496b14b8415 (diff)
downloadwebtools.jsf-bba4d5731f6b6528025d2084030216704e73adf2.tar.gz
webtools.jsf-bba4d5731f6b6528025d2084030216704e73adf2.tar.xz
webtools.jsf-bba4d5731f6b6528025d2084030216704e73adf2.zip
Hotbug request fro 3.2.5 Patch.
Bug 370891 - [hotbug] [JSF2.0] AppConfig validator does not support custom bean scope
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java23
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java17
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java5
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties1
4 files changed, 40 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..bc92fa1d2 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,26 @@ 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..cd0d98b92 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.

Back to the top