Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2008-05-13 14:56:04 -0400
committercbateman2008-05-13 14:56:04 -0400
commitfe420ac083d93c91c3c3cd7582f3c1a3bdcc5013 (patch)
treee210e0f6f481a4d297aa6d72e81f1c2ec628abf3
parent94fe5829410bb55b3ee8d76c6043e4ab25372ca8 (diff)
downloadwebtools.jsf-fe420ac083d93c91c3c3cd7582f3c1a3bdcc5013.tar.gz
webtools.jsf-fe420ac083d93c91c3c3cd7582f3c1a3bdcc5013.tar.xz
webtools.jsf-fe420ac083d93c91c3c3cd7582f3c1a3bdcc5013.zip
Fix for pmc_approved: https://bugs.eclipse.org/bugs/show_bug.cgi?id=202697
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java4
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java26
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DTAppManagerUtil.java43
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java312
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/jsf_html.xml30
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/viewMappings_html.xml53
6 files changed, 383 insertions, 85 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java
index 413819615..a57a94bed 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java
@@ -198,8 +198,8 @@ public final class TypeComparator {
private static boolean canCoerce(final String testType,
final String checkType) {
// can always to coerce to string or object
- if (TypeCoercer.typeIsString(checkType)
- || TypeConstants.TYPE_JAVAOBJECT.equals(checkType))
+ if (TypeCoercer.typeIsString(checkType)/*
+ || TypeConstants.TYPE_JAVAOBJECT.equals(checkType)*/)
{
return true;
} else if (TypeCoercer.typeIsNumeric(checkType)) {
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java
index 34835010a..7a1e581c5 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java
@@ -15,6 +15,7 @@ import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentTypeType;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterClassType;
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterForClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterIdType;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
@@ -66,7 +67,7 @@ public class ImplicitRuntimeJSFAppConfigProvider extends AbstractJSFAppConfigPro
*/
protected void createModel() {
facesConfig = FacesConfigFactory.eINSTANCE.createFacesConfigType();
- //create and add converters
+ //create and add converters by id
EList converters = facesConfig.getConverter();
converters.add(createConverter("BigDecimal")); //$NON-NLS-1$
converters.add(createConverter("BigInteger")); //$NON-NLS-1$
@@ -80,6 +81,15 @@ public class ImplicitRuntimeJSFAppConfigProvider extends AbstractJSFAppConfigPro
converters.add(createConverter("Long")); //$NON-NLS-1$
converters.add(createConverter("Number")); //$NON-NLS-1$
converters.add(createConverter("Short")); //$NON-NLS-1$
+ // converters by for-class (see spec 3.3.3 -- Standard Converter Implementions
+ converters.add(createForClassConverter("java.lang.Boolean", "javax.faces.convert.BooleanConverter"));
+ converters.add(createForClassConverter("java.lang.Byte", "javax.faces.convert.ByteConverter"));
+ converters.add(createForClassConverter("java.lang.Character", "javax.faces.convert.CharacterConverter"));
+ converters.add(createForClassConverter("java.lang.Double", "javax.faces.convert.DoubleConverter"));
+ converters.add(createForClassConverter("java.lang.Float", "javax.faces.convert.FloatConverter"));
+ converters.add(createForClassConverter("java.lang.Integer", "javax.faces.convert.IntegerConverter"));
+ converters.add(createForClassConverter("java.lang.Long", "javax.faces.convert.LongConverter"));
+ converters.add(createForClassConverter("java.lang.Short", "javax.faces.converter.ShortConverter"));
//create and add validators
EList validators = facesConfig.getValidator();
validators.add(createValidator("DoubleRange")); //$NON-NLS-1$
@@ -159,6 +169,20 @@ public class ImplicitRuntimeJSFAppConfigProvider extends AbstractJSFAppConfigPro
return converterType;
}
+ private ConverterType createForClassConverter(String forClass, String converterClass)
+ {
+ ConverterType converterType = FacesConfigFactory.eINSTANCE.createConverterType();
+ //set converter-id
+ ConverterForClassType converterForClass = FacesConfigFactory.eINSTANCE.createConverterForClassType();
+ converterForClass.setTextContent(forClass);
+ converterType.setConverterForClass(converterForClass);
+ //set converter-class
+ ConverterClassType converterClassType = FacesConfigFactory.eINSTANCE.createConverterClassType();
+ converterClassType.setTextContent(converterClass);
+ converterType.setConverterClass(converterClassType);
+ return converterType;
+ }
+
/**
* Creates a {@link ValidatorType} instance.
*
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DTAppManagerUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DTAppManagerUtil.java
index cb5a60b11..8d9781573 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DTAppManagerUtil.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DTAppManagerUtil.java
@@ -15,12 +15,14 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
import org.eclipse.jst.jsf.designtime.context.DTFacesContext;
import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler;
import org.eclipse.jst.jsf.designtime.internal.view.IViewDefnAdapter;
import org.eclipse.jst.jsf.designtime.internal.view.IViewDefnAdapterFactory;
+import org.eclipse.jst.jsf.designtime.internal.view.IViewRootHandle;
import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter;
import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler.ViewHandlerException;
@@ -125,4 +127,45 @@ public class DTAppManagerUtil
return DesignTimeApplicationManager.getInstance(project)
.getViewHandler();
}
+
+ /**
+ * @param context
+ * @return the view root handle from this context or null if can't get one.
+ *
+ */
+ public static IViewRootHandle getViewRootHandle(final IStructuredDocumentContext context)
+ {
+ final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory2.INSTANCE
+ .getWorkspaceContextResolver(context);
+
+ if (resolver == null)
+ {
+ return null;
+ }
+ IProject project = null;
+ project = resolver.getProject();
+
+ if (project == null)
+ {
+ return null;
+ }
+
+ final DesignTimeApplicationManager manager = DesignTimeApplicationManager
+ .getInstance(project);
+
+ if (manager != null)
+ {
+ final IResource res = resolver.getResource();
+ if (res instanceof IFile)
+ {
+ final DTFacesContext facesContext = manager
+ .getFacesContext((IFile) res);
+ if (facesContext != null)
+ {
+ return facesContext.getViewRootHandle();
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
index 01cccedaa..f65e5e1fd 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
@@ -10,30 +10,52 @@
*******************************************************************************/
package org.eclipse.jst.jsf.validation.internal.strategy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.jsf.common.dom.AttrDOMAdapter;
import org.eclipse.jst.jsf.common.dom.AttributeIdentifier;
import org.eclipse.jst.jsf.common.dom.DOMAdapter;
import org.eclipse.jst.jsf.common.internal.types.CompositeType;
import org.eclipse.jst.jsf.common.internal.types.TypeComparator;
import org.eclipse.jst.jsf.common.internal.types.TypeComparatorDiagnosticFactory;
+import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject;
+import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentFactory;
+import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo;
+import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator;
+import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterTypeInfo;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
import org.eclipse.jst.jsf.core.internal.region.Region2AttrAdapter;
+import org.eclipse.jst.jsf.core.internal.region.Region2ElementAdapter;
+import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager;
import org.eclipse.jst.jsf.designtime.DTAppManagerUtil;
+import org.eclipse.jst.jsf.designtime.internal.view.DTUIViewRoot;
+import org.eclipse.jst.jsf.designtime.internal.view.IViewRootHandle;
import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter;
+import org.eclipse.jst.jsf.designtime.internal.view.XMLViewObjectMappingService;
import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler.ViewHandlerException;
import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter.DTELExpression;
+import org.eclipse.jst.jsf.designtime.internal.view.XMLViewObjectMappingService.ElementData;
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterForClassType;
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterType;
import org.eclipse.jst.jsf.metadataprocessors.MetaDataEnabledProcessingFactory;
import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues;
@@ -55,24 +77,27 @@ import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
*
*/
public class AttributeValidatingStrategy extends
- AbstractXMLViewValidationStrategy
+AbstractXMLViewValidationStrategy
{
+ private static final String DISABLE_ALTERATIVE_TYPES_KEY = "jsfCoreDisableConverterValidation"; //$NON-NLS-1$
static final boolean DEBUG;
static
{
final String value = Platform
- .getDebugOption("org.eclipse.jst.jsf.validation.internal.el/debug/jspsemanticsvalidator"); //$NON-NLS-1$
+ .getDebugOption("org.eclipse.jst.jsf.validation.internal.el/debug/jspsemanticsvalidator"); //$NON-NLS-1$
DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
}
/**
* identifier
*/
- public final static String ID = "org.eclipse.jst.jsf.validation.strategy.AttributeValidatingStrategy";
- private final static String DISPLAY_NAME = "Attribute Validator";
+ public final static String ID = "org.eclipse.jst.jsf.validation.strategy.AttributeValidatingStrategy"; //$NON-NLS-1$
+ private final static String DISPLAY_NAME = "Attribute Validator"; //$NON-NLS-1$
private final JSFValidationContext _validationContext;
private final TypeComparator _typeComparator;
+ private Set<String> _conversionTypes;
+
/**
* Default constructor
*
@@ -84,7 +109,9 @@ public class AttributeValidatingStrategy extends
super(ID, DISPLAY_NAME);
_validationContext = validationContext;
- _typeComparator = new TypeComparator(new TypeComparatorDiagnosticFactory(validationContext.getPrefs().getTypeComparatorPrefs()));
+ _typeComparator = new TypeComparator(
+ new TypeComparatorDiagnosticFactory(validationContext
+ .getPrefs().getTypeComparatorPrefs()));
}
@Override
@@ -99,16 +126,18 @@ public class AttributeValidatingStrategy extends
if (domAdapter instanceof AttrDOMAdapter)
{
final Region2AttrAdapter attrAdapter = (Region2AttrAdapter) domAdapter;
- //check that this is attribute value region - 221722
- if (attrAdapter.getAttributeValueRegion() != null) {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(attrAdapter.getDocumentContext()
- .getStructuredDocument(), attrAdapter
- .getOwningElement().getDocumentContext()
- .getDocumentPosition()
- + attrAdapter.getAttributeValueRegion().getStart());
-
- validateAttributeValue(context, attrAdapter);
+ // check that this is attribute value region - 221722
+ if (attrAdapter.getAttributeValueRegion() != null)
+ {
+ final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
+ .getContext(attrAdapter.getDocumentContext()
+ .getStructuredDocument(), attrAdapter
+ .getOwningElement().getDocumentContext()
+ .getDocumentPosition()
+ + attrAdapter.getAttributeValueRegion()
+ .getStart());
+
+ validateAttributeValue(context, attrAdapter);
}
}
}
@@ -128,19 +157,21 @@ public class AttributeValidatingStrategy extends
// dependent on external data (meta-data)
SafeRunner.run(new ISafeRunnable()
{
- public void handleException(Throwable exception)
+ public void handleException(final Throwable exception)
{
JSFCorePlugin.log(String.format(
- "Error validating attribute: %s on element %s",
+ "Error validating attribute: %s on element %s", //$NON-NLS-1$
attrAdapter.getNodeName(), attrAdapter
- .getOwningElement().getNodeName()), exception);
+ .getOwningElement().getNodeName()), exception);
}
public void run() throws Exception
{
+ final Region2ElementAdapter elementAdapter =
+ attrAdapter.getOwningElement();
// if there's elText then validate it
// TODO: this approach will fail with mixed expressions
- if (!checkIfELAndValidate(attrAdapter, context))
+ if (!checkIfELAndValidate(elementAdapter, attrAdapter, context))
{
validateNonELAttributeValue(context, attrAdapter);
}
@@ -148,7 +179,8 @@ public class AttributeValidatingStrategy extends
});
}
- private boolean checkIfELAndValidate(final Region2AttrAdapter attrAdapter,
+ private boolean checkIfELAndValidate(final Region2ElementAdapter elementAdapter,
+ final Region2AttrAdapter attrAdapter,
final IStructuredDocumentContext context)
{
int offsetOfFirstEL = -1;
@@ -168,7 +200,7 @@ public class AttributeValidatingStrategy extends
}
final XMLViewDefnAdapter adapter = DTAppManagerUtil
- .getXMLViewDefnAdapter(context);
+ .getXMLViewDefnAdapter(context);
boolean isEL = false;
if (adapter != null && offsetOfFirstEL != -1)
@@ -181,18 +213,18 @@ public class AttributeValidatingStrategy extends
// string returned by attrAdapter will have the value quotes
// removed, but the region offsets include the quotes.
IStructuredDocumentContext elContext = IStructuredDocumentContextFactory.INSTANCE
- .getContext(context.getStructuredDocument(), context
- .getDocumentPosition()
- + offsetOfFirstEL + 1);
+ .getContext(context.getStructuredDocument(), context
+ .getDocumentPosition()
+ + offsetOfFirstEL + 1);
final DTELExpression elExpression = adapter
- .getELExpression(elContext);
+ .getELExpression(elContext);
if (elExpression != null)
{
final String elText = elExpression.getText();
if (DEBUG)
{
- System.out.println(addDebugSpacer(3) + "EL attrVal= "
+ System.out.println(addDebugSpacer(3) + "EL attrVal= " //$NON-NLS-1$
+ elText);
}
@@ -202,15 +234,16 @@ public class AttributeValidatingStrategy extends
if (_validationContext.shouldValidateEL())
{
// also, skip the validation if the expression is empty
- // or only whitespace, since the parser doesn't handle it
+ // or only whitespace, since the parser doesn't handle
+ // it
// anyway.
- if ("".equals(elText.trim()))
+ if ("".equals(elText.trim())) //$NON-NLS-1$
{
- final int offset = elContext.getDocumentPosition()-1;
- final int length = elText.length()+2;
+ final int offset = elContext.getDocumentPosition() - 1;
+ final int length = elText.length() + 2;
final Diagnostic diagnostic = _validationContext
- .getDiagnosticFactory()
- .create_EMPTY_EL_EXPRESSION();
+ .getDiagnosticFactory()
+ .create_EMPTY_EL_EXPRESSION();
// detected empty EL expression
if (_validationContext.shouldValidateEL())
{
@@ -221,13 +254,16 @@ public class AttributeValidatingStrategy extends
else
{
final List elVals = MetaDataEnabledProcessingFactory
- .getInstance()
- .getAttributeValueRuntimeTypeFeatureProcessors(
- IValidELValues.class, elContext,
- attrAdapter.getAttributeIdentifier());
- final String safeELText = elText.replaceAll("[\n\r\t]", " ");
+ .getInstance()
+ .getAttributeValueRuntimeTypeFeatureProcessors(
+ IValidELValues.class,
+ elContext,
+ attrAdapter
+ .getAttributeIdentifier());
+ final String safeELText = elText.replaceAll(
+ "[\n\r\t]", " "); //$NON-NLS-1$ //$NON-NLS-2$
validateELExpression(context, elContext, elVals,
- attrAdapter.getValue(), safeELText);
+ elementAdapter, attrAdapter, safeELText);
isEL = true;
}
}
@@ -262,7 +298,7 @@ public class AttributeValidatingStrategy extends
final ITextRegionCollection parentRegion = ((ITextRegionCollection) attrValueRegion);
if (parentRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
{
- ITextRegionList regionList = parentRegion.getRegions();
+ final ITextRegionList regionList = parentRegion.getRegions();
if (regionList.size() >= 3)
{
@@ -306,7 +342,8 @@ public class AttributeValidatingStrategy extends
private void validateELExpression(final IStructuredDocumentContext context,
final IStructuredDocumentContext elContext, final List elVals,
- final String attributeVal, final String elText)
+ final Region2ElementAdapter elementAdapter,
+ final Region2AttrAdapter attrAdapter, final String elText)
{
// Call EL validator which will perform at least the syntactical
// validation
@@ -322,6 +359,7 @@ public class AttributeValidatingStrategy extends
for (final Iterator it = elVals.iterator(); it.hasNext();)
{
final IValidELValues elval = (IValidELValues) it.next();
+ final String attributeVal = attrAdapter.getValue();
CompositeType expectedType;
Diagnostic status = null;
try
@@ -330,7 +368,9 @@ public class AttributeValidatingStrategy extends
if (expectedType != null)
{
-
+ expectedType = maybeAddAlternativeTypes(
+ expectedType, exprType, elementAdapter,
+ attrAdapter);
status = _typeComparator.calculateTypeCompatibility(
expectedType, exprType);
if (status.getSeverity() != Diagnostic.OK)
@@ -351,6 +391,167 @@ public class AttributeValidatingStrategy extends
}
}
+ private boolean disableAlternativeTypes()
+ {
+ String res = System.getProperty(DISABLE_ALTERATIVE_TYPES_KEY);
+ if (res == null) {
+ //check env var also
+ res = System.getenv(DISABLE_ALTERATIVE_TYPES_KEY);
+ }
+ if (res != null)
+ {
+ return true;
+ }
+ final IPreferenceStore prefStore = JSFCorePlugin.getDefault().getPreferenceStore();
+ return prefStore.getBoolean("org.eclipse.jst.jsf.core."+DISABLE_ALTERATIVE_TYPES_KEY); //$NON-NLS-1$
+ }
+ /**
+ * @return true if alternative type comparison (i.e. post-conversion) passes
+ */
+ private CompositeType maybeAddAlternativeTypes(
+ final CompositeType expectedType,
+ final CompositeType exprTypes,
+ final Region2ElementAdapter elementAdapter,
+ final Region2AttrAdapter attrAdapter)
+ {
+ if (disableAlternativeTypes())
+ {
+ return expectedType;
+ }
+
+ final IStructuredDocumentContext context = elementAdapter
+ .getDocumentContext();
+ final IViewRootHandle viewRootHandle = DTAppManagerUtil
+ .getViewRootHandle(context);
+ if (viewRootHandle != null)
+ {
+ // ok to call update view root here since validation not called
+ // on the UI thread.
+ final DTUIViewRoot viewRoot = viewRootHandle.updateViewRoot();
+ final IAdaptable serviceAdaptable = viewRoot.getServices();
+ final XMLViewObjectMappingService mappingService = (XMLViewObjectMappingService) serviceAdaptable
+ .getAdapter(XMLViewObjectMappingService.class);
+ if (mappingService != null)
+ {
+ final ElementData elementData = XMLViewObjectMappingService
+ .createElementData(elementAdapter.getNamespace(),
+ elementAdapter.getLocalName(), context,
+ Collections.EMPTY_MAP);
+ final ViewObject viewObject = mappingService
+ .findViewObject(elementData);
+ // if the corresponding view object is a valueholder, then
+ // we need to see if you think there a valid conversion
+ // available
+ if (viewObject instanceof ComponentInfo
+ && ((ComponentInfo) viewObject).getComponentTypeInfo() != null
+ && ((ComponentInfo) viewObject).getComponentTypeInfo()
+ .isInstanceOf(
+ ComponentFactory.INTERFACE_VALUEHOLDER))
+ {
+ final ComponentInfo component = (ComponentInfo) viewObject;
+ // get the original elementData
+ final ElementData mappedElementData = mappingService
+ .findElementData(component);
+ final String propName = mappedElementData
+ .getPropertyName(attrAdapter.getLocalName());
+ if ("value".equals(propName)) //$NON-NLS-1$
+ {
+ // final List converters =
+ // component.getDecorators(ComponentFactory.CONVERTER);
+
+ // (ConverterDecorator) it.next();
+ return createCompositeType(
+ expectedType,
+ exprTypes,
+ component
+ .getDecorators(ComponentFactory.CONVERTER));
+ }
+ }
+ }
+ }
+ // don't add anything by default
+ return expectedType;
+ }
+
+ private CompositeType createCompositeType(final CompositeType initialTypes,
+ final CompositeType testTypes, final List<ConverterDecorator> decorators)
+ {
+ // indicates unknown converter
+ final Set<String> types = new HashSet(Arrays.asList(initialTypes
+ .getSignatures()));
+ // look for converters. If there's one where we don't know the type,
+ // simply copy over the testTypes to force validation to ignore, since
+ // we have no idea.
+ for (final ConverterDecorator decorator : decorators)
+ {
+ if (decorator.getTypeInfo() != null)
+ {
+ final ConverterTypeInfo converterTypeInfo = decorator.getTypeInfo();
+ if (converterTypeInfo.getForClass().length == 0)
+ {
+ types.addAll(Arrays.asList(testTypes.getSignatures()));
+ break;
+ }
+ types.addAll(createSignatures(converterTypeInfo.getForClass()));
+ }
+ }
+ types.addAll(getRegisteredConversionTypesByClass());
+ return new CompositeType(types.toArray(new String[0])
+ , initialTypes.getAssignmentTypeMask());
+ }
+
+ private Set<String> getRegisteredConversionTypesByClass()
+ {
+ if (_conversionTypes == null)
+ {
+ _conversionTypes = new HashSet<String>();
+ final IProject project = _validationContext.getFile().getProject();
+ final JSFAppConfigManager appConfig = JSFAppConfigManager.getInstance(project);
+ final List converters = appConfig.getConverters();
+ for (final Iterator it = converters.iterator(); it.hasNext();)
+ {
+ final ConverterType converterType = (ConverterType) it.next();
+ final ConverterForClassType forClassType = converterType.getConverterForClass();
+ if (forClassType != null)
+ {
+ final String forClass = forClassType.getTextContent();
+ if (forClass != null)
+ {
+ String signature = forClass.trim();
+ try
+ {
+ signature = Signature.createTypeSignature(signature, true);
+ _conversionTypes.add(signature);
+ }
+ catch (final Exception e)
+ {
+ JSFCorePlugin.log(IStatus.INFO, "Could not use registered converter for-class: "+forClass); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ return _conversionTypes;
+ }
+
+ private List<String> createSignatures(final String[] classNames)
+ {
+ final List<String> signatures = new ArrayList<String>();
+ for (final String className : classNames)
+ {
+ try
+ {
+ String signature = Signature.createTypeSignature(className, true);
+ signatures.add(signature);
+ }
+ catch (final Exception e)
+ {
+ JSFCorePlugin.log(e, "Trying to create signature"); //$NON-NLS-1$
+ }
+ }
+ return signatures;
+ }
+
/**
* Validates an attribute value in context using the JSF metadata processing
* framework
@@ -372,24 +573,23 @@ public class AttributeValidatingStrategy extends
// else validate as static attribute value
if (DEBUG)
{
- System.out.println(addDebugSpacer(3) + "attrVal= "
- + (attributeValue != null ? attributeValue : "null"));
+ System.out.println(addDebugSpacer(3) + "attrVal= " //$NON-NLS-1$
+ + (attributeValue != null ? attributeValue : "null")); //$NON-NLS-1$
}
final AttributeIdentifier attributeId = attrAdapter
- .getAttributeIdentifier();
+ .getAttributeIdentifier();
if (attributeId.getTagIdentifier() == null
|| attributeId.getTagIdentifier().getTagName() == null
- || attributeId.getTagIdentifier().getTagName() == null
|| attributeId.getName() == null)
{
return;
}
final List vv = MetaDataEnabledProcessingFactory.getInstance()
- .getAttributeValueRuntimeTypeFeatureProcessors(
- IValidValues.class, context, attributeId);
+ .getAttributeValueRuntimeTypeFeatureProcessors(
+ IValidValues.class, context, attributeId);
if (!vv.isEmpty())
{
for (final Iterator it = vv.iterator(); it.hasNext();)
@@ -399,29 +599,29 @@ public class AttributeValidatingStrategy extends
{
if (DEBUG)
{
- System.out.println(addDebugSpacer(4) + "NOT VALID ");
+ System.out.println(addDebugSpacer(4) + "NOT VALID "); //$NON-NLS-1$
}
for (final Iterator msgs = v.getValidationMessages()
.iterator(); msgs.hasNext();)
{
final IValidationMessage msg = (IValidationMessage) msgs
- .next();
+ .next();
reportValidationMessage(createValidationMessage(
context, attributeValue, msg.getSeverity(), msg
- .getMessage(), _validationContext
- .getFile()), context, attributeValue);
+ .getMessage(), _validationContext
+ .getFile()), context, attributeValue);
}
}
else if (DEBUG)
{
- System.out.println(addDebugSpacer(5) + "VALID ");
+ System.out.println(addDebugSpacer(5) + "VALID "); //$NON-NLS-1$
}
}
}
else if (DEBUG)
{
- System.out.println(addDebugSpacer(4) + "NO META DATA ");
+ System.out.println(addDebugSpacer(4) + "NO META DATA "); //$NON-NLS-1$
}
}
@@ -440,15 +640,15 @@ public class AttributeValidatingStrategy extends
final IFile file)
{
// TODO: need factory
- final Diagnostic diagnostic = new BasicDiagnostic(severity, "", -1,
+ final Diagnostic diagnostic = new BasicDiagnostic(severity, "", -1, //$NON-NLS-1$
msg, null);
return diagnostic;
}
private String addDebugSpacer(final int count)
{
- final String TAB = "\t";
- final StringBuffer ret = new StringBuffer("");
+ final String TAB = "\t"; //$NON-NLS-1$
+ final StringBuffer ret = new StringBuffer(""); //$NON-NLS-1$
for (int i = 0; i <= count; i++)
{
ret.append(TAB);
diff --git a/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/jsf_html.xml b/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/jsf_html.xml
index 51a7017ef..53054127a 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/jsf_html.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/jsf_html.xml
@@ -535,9 +535,17 @@
</trait>
<trait id="default-value">
<value>lineDirection</value>
- </trait>
- </entity>
- </entity>
+ </trait>
+ </entity>
+ <entity id="value">
+ <trait id="attribute-value-runtime-type">
+ <value>org.eclipse.jst.jsf.core.attributevalues.ValueType</value>
+ </trait>
+ <trait id="runtime-type-setter-required">
+ <value>true</value>
+ </trait>
+ </entity>
+ </entity>
<entity id="selectManyListbox" type="tag">
<include-entity-group id="basic-jsf-html-attributes"/>
<include-entity-group id="common-jsf-html-attributes"/>
@@ -568,6 +576,14 @@
</satisfies-set>
</value>
</trait>
+ <entity id="value">
+ <trait id="attribute-value-runtime-type">
+ <value>org.eclipse.jst.jsf.core.attributevalues.ValueType</value>
+ </trait>
+ <trait id="runtime-type-setter-required">
+ <value>true</value>
+ </trait>
+ </entity>
</entity>
<entity id="selectManyMenu" type="tag">
<include-entity-group id="basic-jsf-html-attributes"/>
@@ -598,6 +614,14 @@
</satisfies-set>
</value>
</trait>
+ <entity id="value">
+ <trait id="attribute-value-runtime-type">
+ <value>org.eclipse.jst.jsf.core.attributevalues.ValueType</value>
+ </trait>
+ <trait id="runtime-type-setter-required">
+ <value>true</value>
+ </trait>
+ </entity>
</entity>
<entity id="selectOneListbox" type="tag">
<include-entity-group id="basic-jsf-html-attributes"/>
diff --git a/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/viewMappings_html.xml b/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/viewMappings_html.xml
index b81a5c6d9..9c94c712f 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/viewMappings_html.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.standard.tagsupport/metadata/viewMappings_html.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<md:metadatamodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:viewMap="http://org.eclipse.jst.jsf.core/componentMapping.ecore" xmlns:md="http://org.eclipse.jst.jsf.common.metadata/metadata.ecore" xsi:noNamespaceSchemaLocation="http://org.eclipse.jst.jsf.core/componentMapping.ecore" id="http://java.sun.com/jsf/html" type="tagFile">
<entity id="selectOneMenu" type="tag">
+ <include-entity-group id="common-valueholder-attributes"/>
<trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>
@@ -24,7 +25,8 @@
</trait>
</entity>
<entity id="selectManyListbox" type="tag">
- <trait id="viewElementMapping">
+ <include-entity-group id="common-valueholder-attributes"/>
+ <trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>
<typeInfo xsi:type="viewMap:ComponentTypeInfo_">
@@ -144,6 +146,7 @@
</trait>
</entity>
<entity id="selectManyMenu" type="tag">
+ <include-entity-group id="common-valueholder-attributes"/>
<trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>
@@ -167,7 +170,8 @@
</trait>
</entity>
<entity id="selectOneRadio" type="tag">
- <trait id="viewElementMapping">
+ <include-entity-group id="common-valueholder-attributes"/>
+ <trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>
<typeInfo xsi:type="viewMap:ComponentTypeInfo_">
@@ -209,7 +213,8 @@
</trait>
</entity>
<entity id="selectOneListbox" type="tag">
- <trait id="viewElementMapping">
+ <include-entity-group id="common-valueholder-attributes"/>
+ <trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>
<typeInfo xsi:type="viewMap:ComponentTypeInfo_">
@@ -295,26 +300,27 @@
</trait>
</entity>
<entity id="selectBooleanCheckbox" type="tag">
- <trait id="viewElementMapping">
- <md:value xsi:type="viewMap:TagMapping">
- <versionedTagToViewMappings>
- <typeInfo xsi:type="viewMap:ComponentTypeInfo_">
- <className>javax.faces.component.html.HtmlSelectBooleanCheckbox</className>
- <superClasses>javax.faces.component.UISelectBoolean</superClasses>
- <superClasses>javax.faces.component.UIInput</superClasses>
- <superClasses>javax.faces.component.UIOutput</superClasses>
- <superClasses>javax.faces.component.UIComponentBase</superClasses>
- <superClasses>javax.faces.component.UIComponent</superClasses>
- <superClasses>java.lang.Object</superClasses>
- <interfaces>javax.faces.component.EditableValueHolder</interfaces>
- <interfaces>javax.faces.component.ValueHolder</interfaces>
- <interfaces>javax.faces.component.StateHolder</interfaces>
- <componentType>javax.faces.HtmlSelectBooleanCheckbox</componentType>
- <componentFamily>javax.faces.SelectBoolean</componentFamily>
- <renderType>javax.faces.Checkbox</renderType>
- </typeInfo>
- </versionedTagToViewMappings>
- </md:value>
+ <include-entity-group id="common-valueholder-attributes"/>
+ <trait id="viewElementMapping">
+ <md:value xsi:type="viewMap:TagMapping">
+ <versionedTagToViewMappings>
+ <typeInfo xsi:type="viewMap:ComponentTypeInfo_">
+ <className>javax.faces.component.html.HtmlSelectBooleanCheckbox</className>
+ <superClasses>javax.faces.component.UISelectBoolean</superClasses>
+ <superClasses>javax.faces.component.UIInput</superClasses>
+ <superClasses>javax.faces.component.UIOutput</superClasses>
+ <superClasses>javax.faces.component.UIComponentBase</superClasses>
+ <superClasses>javax.faces.component.UIComponent</superClasses>
+ <superClasses>java.lang.Object</superClasses>
+ <interfaces>javax.faces.component.EditableValueHolder</interfaces>
+ <interfaces>javax.faces.component.ValueHolder</interfaces>
+ <interfaces>javax.faces.component.StateHolder</interfaces>
+ <componentType>javax.faces.HtmlSelectBooleanCheckbox</componentType>
+ <componentFamily>javax.faces.SelectBoolean</componentFamily>
+ <renderType>javax.faces.Checkbox</renderType>
+ </typeInfo>
+ </versionedTagToViewMappings>
+ </md:value>
</trait>
</entity>
<entity id="outputText" type="tag">
@@ -339,6 +345,7 @@
</trait>
</entity>
<entity id="selectManyCheckbox" type="tag">
+ <include-entity-group id="common-valueholder-attributes"/>
<trait id="viewElementMapping">
<md:value xsi:type="viewMap:TagMapping">
<versionedTagToViewMappings>

Back to the top