Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.myfaces.el.unified.resolver;
import java.beans.BeanInfo;
import java.beans.FeatureDescriptor;
import java.beans.PropertyDescriptor;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.CompositeComponentExpressionHolder;
/**
* Composite component attribute EL resolver. See JSF spec, section 5.6.2.2.
*/
public final class CompositeComponentELResolver extends ELResolver
{
private static final String ATTRIBUTES_MAP = "attrs";
private static final String PARENT_COMPOSITE_COMPONENT = "parent";
private static final String COMPOSITE_COMPONENT_ATTRIBUTES_MAPS =
"org.apache.myfaces.COMPOSITE_COMPONENT_ATTRIBUTES_MAPS";
@Override
public Class getCommonPropertyType(ELContext context, Object base)
{
// Per the spec, return String.class.
return String.class;
}
@Override
public Iterator getFeatureDescriptors(ELContext context,
Object base)
{
// Per the spec, do nothing.
return null;
}
@Override
public Class getType(ELContext context, Object base, Object property)
{
// Per the spec, return null.
return null;
}
@Override
public Object getValue(ELContext context, Object base, Object property)
{
// Per the spec: base must not be null, an instance of UIComponent, and a composite
// component. Property must be a String.
if ((base != null) && (base instanceof UIComponent)
&& UIComponent.isCompositeComponent((UIComponent) base)
&& (property != null))
{
String propName = property.toString();
UIComponent baseComponent = (UIComponent) base;
if (propName.equals(ATTRIBUTES_MAP))
{
// Return a wrapped map that delegates all calls except get() and put().
context.setPropertyResolved(true);
return _getCompositeComponentAttributesMapWrapper(baseComponent, context);
}
else if (propName.equals(PARENT_COMPOSITE_COMPONENT))
{
// Return the parent.
context.setPropertyResolved(true);
return UIComponent.getCompositeComponentParent(baseComponent);
}
}
// Otherwise, spec says to do nothing (return null).
return null;
}
@SuppressWarnings("unchecked")
private Map _getCompositeComponentAttributesMapWrapper(
UIComponent baseComponent, ELContext elContext)
{
Map