Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5417: remove "optimization" when composite attribute default is literal instead of VE, this will fail when the final value itself is VE #5418

Merged
merged 1 commit into from Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -27,7 +27,6 @@
import static jakarta.faces.component.UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES;
import static jakarta.faces.component.UIComponent.BEANINFO_KEY;
import static jakarta.faces.component.UIComponent.COMPOSITE_COMPONENT_TYPE_KEY;
import static java.beans.Introspector.getBeanInfo;
import static java.beans.PropertyEditorManager.findEditor;
import static java.text.MessageFormat.format;
import static java.util.Collections.unmodifiableMap;
Expand All @@ -37,7 +36,6 @@

import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
Expand All @@ -57,16 +55,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import com.sun.faces.application.ApplicationAssociate;
import com.sun.faces.application.ConverterPropertyEditorFactory;
import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap;
import com.sun.faces.cdi.CdiUtils;
import com.sun.faces.config.WebConfiguration;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.ReflectionUtils;
import com.sun.faces.util.Util;

import jakarta.el.ExpressionFactory;
import jakarta.el.ValueExpression;
import jakarta.enterprise.inject.spi.BeanManager;
Expand All @@ -83,6 +71,16 @@
import jakarta.faces.validator.Validator;
import jakarta.faces.view.ViewDeclarationLanguage;

import com.sun.faces.application.ApplicationAssociate;
import com.sun.faces.application.ConverterPropertyEditorFactory;
import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap;
import com.sun.faces.cdi.CdiUtils;
import com.sun.faces.config.WebConfiguration;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.ReflectionUtils;
import com.sun.faces.util.Util;

public class InstanceFactory {

// Log instance for this class
Expand Down Expand Up @@ -805,21 +803,12 @@ private void pushDeclaredDefaultValuesToAttributesMap(FacesContext context, Bean
ExpressionFactory expressionFactory) {

Collection<String> attributesWithDeclaredDefaultValues = null;
PropertyDescriptor[] propertyDescriptors = null;

for (PropertyDescriptor propertyDescriptor : componentMetadata.getPropertyDescriptors()) {
Object defaultValue = propertyDescriptor.getValue("default");

if (defaultValue != null) {
String key = propertyDescriptor.getName();
boolean isLiteralText = false;

if (defaultValue instanceof ValueExpression) {
isLiteralText = ((ValueExpression) defaultValue).isLiteralText();
if (isLiteralText) {
defaultValue = ((ValueExpression) defaultValue).getValue(context.getELContext());
}
}

// Ensure this attribute is not a method-signature. method-signature
// declared default values are handled in retargetMethodExpressions.
Expand All @@ -834,24 +823,6 @@ private void pushDeclaredDefaultValuesToAttributesMap(FacesContext context, Bean
}
}
attributesWithDeclaredDefaultValues.add(key);

// Only store the attribute if it is literal text. If it
// is a ValueExpression, it will be handled explicitly in
// CompositeComponentAttributesELResolver.ExpressionEvalMap.get().
// If it is a MethodExpression, it will be dealt with in
// retargetMethodExpressions.
if (isLiteralText) {
try {
if (propertyDescriptors == null) {
propertyDescriptors = getBeanInfo(component.getClass()).getPropertyDescriptors();
}
} catch (IntrospectionException e) {
throw new FacesException(e);
}

defaultValue = convertValueToTypeIfNecessary(key, defaultValue, propertyDescriptors, expressionFactory);
attrs.put(key, defaultValue);
}
}
}
}
Expand Down