You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/10/25 14:33:10 UTC
svn commit: r1188631 [2/2] - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: context/
context/servlet/ renderkit/ view/facelets/ webapp/
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=1188631&r1=1188630&r2=1188631&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java Tue Oct 25 12:33:10 2011
@@ -127,10 +127,10 @@ import org.apache.myfaces.view.facelets.
/**
* This class represents the abstraction of Facelets as a ViewDeclarationLanguage.
- *
+ *
* @author Simon Lessard (latest modification by $Author$)
* @version $Revision$ $Date$
- *
+ *
* @since 2.0
*/
public class FaceletViewDeclarationLanguage extends ViewDeclarationLanguageBase
@@ -141,35 +141,35 @@ public class FaceletViewDeclarationLangu
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
private static final Class<?>[] VALUE_CHANGE_LISTENER_SIGNATURE = new Class[]{ValueChangeEvent.class};
-
+
private static final Class<?>[] ACTION_LISTENER_SIGNATURE = new Class[]{ActionEvent.class};
-
+
private static final Class<?>[] VALIDATOR_SIGNATURE = new Class[]{FacesContext.class, UIComponent.class, Object.class};
-
+
public static final String CHARACTER_ENCODING_KEY = "javax.faces.request.charset";
public final static long DEFAULT_REFRESH_PERIOD = 2;
public final static long DEFAULT_REFRESH_PERIOD_PRODUCTION = -1;
public final static String DEFAULT_CHARACTER_ENCODING = "UTF-8";
-
+
//public final static String PARAM_BUFFER_SIZE = "javax.faces.FACELETS_BUFFER_SIZE";
-
+
/**
* Define the default buffer size value passed to ExternalContext.setResponseBufferResponse() and in a
* servlet environment to HttpServletResponse.setBufferSize().
*/
- @JSFWebConfigParam(since="2.0", alias="facelets.BUFFER_SIZE", classType="java.lang.Integer", tags="performance",
- desc="Define the default buffer size value passed to ExternalContext.setResponseBufferResponse() and in a servlet environment to HttpServletResponse.setBufferSize()")
+ @JSFWebConfigParam(since = "2.0", alias = "facelets.BUFFER_SIZE", classType = "java.lang.Integer", tags = "performance",
+ desc = "Define the default buffer size value passed to ExternalContext.setResponseBufferResponse() and in a servlet environment to HttpServletResponse.setBufferSize()")
public final static String PARAM_BUFFER_SIZE = "javax.faces.FACELETS_BUFFER_SIZE";
-
+
/**
* Define the default buffer size value passed to ExternalContext.setResponseBufferResponse() and in a
* servlet environment to HttpServletResponse.setBufferSize().
*/
- @JSFWebConfigParam(since="2.0", deprecated=true, classType="java.lang.Integer")
+ @JSFWebConfigParam(since = "2.0", deprecated = true, classType = "java.lang.Integer")
private final static String PARAM_BUFFER_SIZE_DEPRECATED = "facelets.BUFFER_SIZE";
-
+
private final static String[] PARAMS_BUFFER_SIZE = {PARAM_BUFFER_SIZE, PARAM_BUFFER_SIZE_DEPRECATED};
//private final static String PARAM_BUILD_BEFORE_RESTORE = "facelets.BUILD_BEFORE_RESTORE";
@@ -178,16 +178,16 @@ public class FaceletViewDeclarationLangu
* Set of class names, separated by ';', implementing TagDecorator interface, used to transform
* a view definition in a facelet abstract syntax tree, that is used later to generate a component tree.
*/
- @JSFWebConfigParam(since="2.0", alias="facelets.DECORATORS")
+ @JSFWebConfigParam(since = "2.0", alias = "facelets.DECORATORS")
public final static String PARAM_DECORATORS = "javax.faces.FACELETS_DECORATORS";
-
+
/**
* Set of class names, separated by ';', implementing TagDecorator interface, used to transform
* a view definition in a facelet abstract syntax tree, that is used later to generate a component tree.
*/
- @JSFWebConfigParam(since="2.0", deprecated=true)
+ @JSFWebConfigParam(since = "2.0", deprecated = true)
private final static String PARAM_DECORATORS_DEPRECATED = "facelets.DECORATORS";
-
+
private final static String[] PARAMS_DECORATORS = {PARAM_DECORATORS, PARAM_DECORATORS_DEPRECATED};
/**
@@ -199,95 +199,95 @@ public class FaceletViewDeclarationLangu
/**
* Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.
*/
- @JSFWebConfigParam(since="2.0", desc="Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.",
- alias="facelets.LIBRARIES")
+ @JSFWebConfigParam(since = "2.0", desc = "Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.",
+ alias = "facelets.LIBRARIES")
public final static String PARAM_LIBRARIES = "javax.faces.FACELETS_LIBRARIES";
-
+
/**
* Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.
*/
- @JSFWebConfigParam(since="2.0", desc="Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.",
- deprecated=true)
+ @JSFWebConfigParam(since = "2.0", desc = "Set of .taglib.xml files, separated by ';' that should be loaded by facelet engine.",
+ deprecated = true)
private final static String PARAM_LIBRARIES_DEPRECATED = "facelets.LIBRARIES";
-
+
private final static String[] PARAMS_LIBRARIES = {PARAM_LIBRARIES, PARAM_LIBRARIES_DEPRECATED};
/**
* Define the period used to refresh the facelet abstract syntax tree from the view definition file.
- *
+ *
* <p>By default is infinite (no active).</p>
*/
- @JSFWebConfigParam(since="2.0", defaultValue="-1", alias="facelets.REFRESH_PERIOD", classType="java.lang.Long", tags="performance")
+ @JSFWebConfigParam(since = "2.0", defaultValue = "-1", alias = "facelets.REFRESH_PERIOD", classType = "java.lang.Long", tags = "performance")
public final static String PARAM_REFRESH_PERIOD = "javax.faces.FACELETS_REFRESH_PERIOD";
-
+
/**
* Define the period used to refresh the facelet abstract syntax tree from the view definition file.
- *
+ *
* <p>By default is infinite (no active).</p>
*/
- @JSFWebConfigParam(since="2.0", defaultValue="-1", deprecated=true)
+ @JSFWebConfigParam(since = "2.0", defaultValue = "-1", deprecated = true)
private final static String PARAM_REFRESH_PERIOD_DEPRECATED = "facelets.REFRESH_PERIOD";
-
+
private final static String[] PARAMS_REFRESH_PERIOD = {PARAM_REFRESH_PERIOD, PARAM_REFRESH_PERIOD_DEPRECATED};
-
+
/**
* Class implementing ResourceResolver interface used to locate facelet resources.
*/
- @JSFWebConfigParam(since="2.0", alias="facelets.RESOURCE_RESOLVER")
+ @JSFWebConfigParam(since = "2.0", alias = "facelets.RESOURCE_RESOLVER")
public final static String PARAM_RESOURCE_RESOLVER = "javax.faces.FACELETS_RESOURCE_RESOLVER";
-
+
/**
* Class implementing ResourceResolver interface used to locate facelet resources.
*/
- @JSFWebConfigParam(since="2.0", deprecated=true)
+ @JSFWebConfigParam(since = "2.0", deprecated = true)
private final static String PARAM_RESOURCE_RESOLVER_DEPRECATED = "facelets.RESOURCE_RESOLVER";
-
+
private final static String[] PARAMS_RESOURCE_RESOLVER = {PARAM_RESOURCE_RESOLVER, PARAM_RESOURCE_RESOLVER_DEPRECATED};
-
+
/**
* Skip comments found on a facelet file.
*/
- @JSFWebConfigParam(since="2.0", alias="facelets.SKIP_COMMENTS")
+ @JSFWebConfigParam(since = "2.0", alias = "facelets.SKIP_COMMENTS")
public final static String PARAM_SKIP_COMMENTS = "javax.faces.FACELETS_SKIP_COMMENTS";
-
+
/**
* Skip comments found on a facelet file.
*/
- @JSFWebConfigParam(since="2.0", deprecated=true)
+ @JSFWebConfigParam(since = "2.0", deprecated = true)
private final static String PARAM_SKIP_COMMENTS_DEPRECATED = "facelets.SKIP_COMMENTS";
-
- @JSFWebConfigParam(since="2.1", defaultValue="false", expectedValues="true, false", tags="performance")
+
+ @JSFWebConfigParam(since = "2.1", defaultValue = "false", expectedValues = "true, false", tags = "performance")
private final static String PARAM_MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW = "org.apache.myfaces.MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW";
-
+
private final static String[] PARAMS_SKIP_COMMENTS = {PARAM_SKIP_COMMENTS, PARAM_SKIP_COMMENTS_DEPRECATED};
//public final static String PARAM_VIEW_MAPPINGS = "javax.faces.FACELETS_VIEW_MAPPINGS";
-
+
//private final static String PARAM_VIEW_MAPPINGS_DEPRECATED = "facelets.VIEW_MAPPINGS";
-
+
public final static String FILLED_VIEW = "org.apache.myfaces.FILLED_VIEW";
-
+
//BEGIN CONSTANTS SET ON BUILD VIEW
//public final static String BUILDING_COMPOSITE_COMPONENT_METADATA = "org.apache.myfaces.BUILDING_COMPOSITE_COMPONENT_METADATA";
-
+
public final static String BUILDING_VIEW_METADATA = "org.apache.myfaces.BUILDING_VIEW_METADATA";
-
+
public final static String REFRESHING_TRANSIENT_BUILD = "org.apache.myfaces.REFRESHING_TRANSIENT_BUILD";
-
+
public final static String REFRESH_TRANSIENT_BUILD_ON_PSS = "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS";
-
+
public final static String USING_PSS_ON_THIS_VIEW = "org.apache.myfaces.USING_PSS_ON_THIS_VIEW";
-
+
public final static String REMOVING_COMPONENTS_BUILD = "org.apache.myfaces.REMOVING_COMPONENTS_BUILD";
//END CONSTANTS SET ON BUILD VIEW
-
+
/**
* Marker to indicate tag handlers the view currently being built is using
* partial state saving and it is necessary to call UIComponent.markInitialState
* after component instances are populated.
*/
public final static String MARK_INITIAL_STATE_KEY = "javax.faces.view.ViewDeclarationLanguage.IS_BUILDING_INITIAL_STATE";
-
+
public final static String CLEAN_TRANSIENT_BUILD_ON_RESTORE = "org.apache.myfaces.CLEAN_TRANSIENT_BUILD_ON_RESTORE";
private final static String STATE_KEY = "<!-...@-->";
@@ -306,36 +306,36 @@ public class FaceletViewDeclarationLangu
private FaceletFactory _faceletFactory;
private StateManagementStrategy _stateMgmtStrategy;
-
+
private boolean _partialStateSaving;
-
+
private boolean _refreshTransientBuildOnPSS;
-
+
private boolean _refreshTransientBuildOnPSSAuto;
-
+
private Set<String> _viewIds;
-
+
private boolean _markInitialStateWhenApplyBuildView;
-
+
private final ViewDeclarationLanguageStrategy _strategy;
-
+
private ResourceResolver _resourceResolver;
/**
- *
+ *
*/
public FaceletViewDeclarationLanguage(FacesContext context)
{
initialize(context);
_strategy = new FaceletViewDeclarationLanguageStrategy();
}
-
+
public FaceletViewDeclarationLanguage(FacesContext context, ViewDeclarationLanguageStrategy strategy)
{
initialize(context);
_strategy = strategy;
}
-
+
@Override
public String getId()
@@ -363,7 +363,7 @@ public class FaceletViewDeclarationLangu
{
return;
}
-
+
// setup our viewId
String renderedViewId = getRenderedViewId(context, view.getViewId());
@@ -377,7 +377,7 @@ public class FaceletViewDeclarationLangu
boolean usePartialStateSavingOnThisView = _usePartialStateSavingOnThisView(renderedViewId);
boolean refreshTransientBuild = (view.getChildCount() > 0);
boolean refreshTransientBuildOnPSS = (usePartialStateSavingOnThisView && _refreshTransientBuildOnPSS);
-
+
if (usePartialStateSavingOnThisView)
{
// Before apply we need to make sure the current view has
@@ -386,9 +386,9 @@ public class FaceletViewDeclarationLangu
// from UIViewRoot.
if (view.getId() == null)
{
- view.setId(view.createUniqueId(context,null));
+ view.setId(view.createUniqueId(context, null));
}
-
+
context.getAttributes().put(USING_PSS_ON_THIS_VIEW, Boolean.TRUE);
//Add a key to indicate ComponentTagHandlerDelegate to
//call UIComponent.markInitialState after it is populated
@@ -409,7 +409,7 @@ public class FaceletViewDeclarationLangu
if (refreshTransientBuild)
{
context.getAttributes().put(REFRESHING_TRANSIENT_BUILD, Boolean.TRUE);
-
+
// In theory, this should be disabled on ComponentTagHandlerDelegate,
// otherwise we could lost PostAddToViewEvent / PreRemoveFromViewEvent
// caused by c:if effect or facelets cleanup algorithm
@@ -427,7 +427,7 @@ public class FaceletViewDeclarationLangu
if (refreshTransientBuild)
{
//context.setProcessingEvents(true);
-
+
if (!usePartialStateSavingOnThisView || refreshTransientBuildOnPSS)
{
// When the facelet is applied, all components are removed and added from view,
@@ -440,11 +440,11 @@ public class FaceletViewDeclarationLangu
//FaceletViewDeclarationLanguage._publishPostAddToViewEvent(context, view);
FaceletViewDeclarationLanguage._publishPostBuildComponentTreeOnRestoreViewEvent(context, view);
}
-
+
context.getAttributes().remove(REFRESHING_TRANSIENT_BUILD);
}
- }
-
+ }
+
// set this view as filled
if (refreshTransientBuild)
{
@@ -464,7 +464,7 @@ public class FaceletViewDeclarationLangu
{
setFilledView(context, view);
}
-
+
// Suscribe listeners if we are using partialStateSaving
if (usePartialStateSavingOnThisView)
{
@@ -475,12 +475,12 @@ public class FaceletViewDeclarationLangu
{
if (_markInitialStateWhenApplyBuildView)
{
- if (!refreshTransientBuildOnPSS ||
- !view.getAttributes().containsKey(DefaultFaceletsStateManagementStrategy.COMPONENT_ADDED_AFTER_BUILD_VIEW))
+ if (!refreshTransientBuildOnPSS ||
+ !view.getAttributes().containsKey(DefaultFaceletsStateManagementStrategy.COMPONENT_ADDED_AFTER_BUILD_VIEW))
{
view.markInitialState();
}
-
+
//Remove the key that indicate we need to call UIComponent.markInitialState
//on the current tree
context.getAttributes().remove(MARK_INITIAL_STATE_KEY);
@@ -495,7 +495,7 @@ public class FaceletViewDeclarationLangu
context.getAttributes().remove(MARK_INITIAL_STATE_KEY);
}
}
-
+
// We need to suscribe the listeners of changes in the component tree
// only the first time here. Later we suscribe this listeners on
// DefaultFaceletsStateManagement.restoreView after calling
@@ -505,19 +505,19 @@ public class FaceletViewDeclarationLangu
{
((DefaultFaceletsStateManagementStrategy) getStateManagementStrategy(context, view.getViewId())).suscribeListeners(view);
}
-
+
context.getAttributes().remove(USING_PSS_ON_THIS_VIEW);
}
-
+
// Remove this var from faces context because this one prevent AjaxHandler
// register the standard script library on Post-Redirect-Get pattern or
// in the next view
context.getAttributes().remove(AjaxHandler.STANDARD_JSF_AJAX_LIBRARY_LOADED);
}
-
+
private void _markInitialStateOnView(final UIViewRoot view, final boolean refreshTransientBuildOnPSS)
{
- if (!refreshTransientBuildOnPSS ||
+ if (!refreshTransientBuildOnPSS ||
!view.getAttributes().containsKey(DefaultFaceletsStateManagementStrategy.COMPONENT_ADDED_AFTER_BUILD_VIEW))
{
if (!view.isTransient())
@@ -525,7 +525,7 @@ public class FaceletViewDeclarationLangu
view.markInitialState();
}
}
-
+
int childCount = view.getChildCount();
if (childCount > 0)
{
@@ -554,11 +554,11 @@ public class FaceletViewDeclarationLangu
}
}
}
-
+
private void _markInitialState(final UIComponent component)
{
component.markInitialState();
-
+
final int childCount = component.getChildCount();
if (childCount > 0)
{
@@ -591,7 +591,7 @@ public class FaceletViewDeclarationLangu
private static void _publishPreRemoveFromViewEvent(FacesContext context, UIComponent component)
{
context.getApplication().publishEvent(context, PreRemoveFromViewEvent.class, component.getClass(), component);
-
+
if (component.getChildCount() > 0)
{
for (int j = 0, childCount = component.getChildCount(); j < childCount; j++)
@@ -606,13 +606,13 @@ public class FaceletViewDeclarationLangu
{
_publishPreRemoveFromViewEvent(context, child);
}
- }
- }
-
+ }
+ }
+
public static void _publishPostBuildComponentTreeOnRestoreViewEvent(FacesContext context, UIComponent component)
{
context.getApplication().publishEvent(context, PostBuildComponentTreeOnRestoreViewEvent.class, component.getClass(), component);
-
+
if (component.getChildCount() > 0)
{
// PostAddToViewEvent could cause component relocation
@@ -627,13 +627,13 @@ public class FaceletViewDeclarationLangu
child = children.get(i);
// Iterate over the same index if the component was removed
// This prevents skip components when processing
- do
+ do
{
_publishPostBuildComponentTreeOnRestoreViewEvent(context, child);
currentChild = child;
}
while ((i < children.size()) &&
- ((child = children.get(i)) != currentChild) );
+ ((child = children.get(i)) != currentChild));
i++;
}
}
@@ -645,7 +645,7 @@ public class FaceletViewDeclarationLangu
}
}
}
-
+
private boolean isFilledView(FacesContext context, UIViewRoot view)
{
// The view is only built on restoreView or renderView, but if
@@ -658,7 +658,7 @@ public class FaceletViewDeclarationLangu
// partial state saving is not used.
//return view.getAttributes().containsKey(FILLED_VIEW);
}
-
+
private void setFilledView(FacesContext context, UIViewRoot view)
{
context.getAttributes().put(view, Boolean.TRUE);
@@ -668,20 +668,20 @@ public class FaceletViewDeclarationLangu
// partial state saving is not used.
// view.getAttributes().put(FILLED_VIEW, Boolean.TRUE);
}
-
+
/**
* retargetMethodExpressions(FacesContext, UIComponent) has some clues about the behavior of this method
- *
+ *
* {@inheritDoc}
*/
@Override
public BeanInfo getComponentMetadata(FacesContext context, Resource componentResource)
{
BeanInfo beanInfo = null;
-
+
checkNull(context, "context");
-
- try
+
+ try
{
Facelet compositeComponentFacelet;
FaceletFactory.setInstance(_faceletFactory);
@@ -694,56 +694,56 @@ public class FaceletViewDeclarationLangu
FaceletFactory.setInstance(null);
}
//context.getAttributes().put(BUILDING_COMPOSITE_COMPONENT_METADATA, Boolean.TRUE);
-
+
// Create a temporal tree where all components will be put, but we are only
// interested in metadata.
UINamingContainer compositeComponentBase = (UINamingContainer) context.getApplication().createComponent(UINamingContainer.COMPONENT_TYPE);
-
+
// Fill the component resource key, because this information should be available
// on metadata to recognize which is the component used as composite component base.
// Since this method is called from Application.createComponent(FacesContext,Resource),
// and in that specific method this key is updated, this is the best option we
// have for recognize it (also this key is used by UIComponent.isCompositeComponent)
compositeComponentBase.getAttributes().put(Resource.COMPONENT_RESOURCE_KEY, componentResource);
-
+
// According to UserTagHandler, in this point we need to wrap the facelet
// VariableMapper, so local changes are applied on "page context", but
// data is retrieved from full context
FaceletContext faceletContext = (FaceletContext) context.
- getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
+ getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
VariableMapper orig = faceletContext.getVariableMapper();
try
{
faceletContext.setVariableMapper(new VariableMapperWrapper(orig));
-
+
compositeComponentBase.pushComponentToEL(context, compositeComponentBase);
-
+
compositeComponentFacelet.apply(context, compositeComponentBase);
-
+
compositeComponentBase.popComponentFromEL(context);
}
finally
{
faceletContext.setVariableMapper(orig);
}
-
+
beanInfo = (BeanInfo) compositeComponentBase.getAttributes().get(UIComponent.BEANINFO_KEY);
}
- catch(IOException e)
+ catch (IOException e)
{
throw new FacesException(e);
}
//finally
//{
- //context.getAttributes().remove(BUILDING_COMPOSITE_COMPONENT_METADATA);
+ //context.getAttributes().remove(BUILDING_COMPOSITE_COMPONENT_METADATA);
//}
-
+
return beanInfo;
}
-
+
/**
* Check if the current facelet applied is used to build composite component metadata.
- *
+ *
* @param context
* @return
*/
@@ -751,10 +751,10 @@ public class FaceletViewDeclarationLangu
//{
// return context.getAttributes().containsKey(BUILDING_COMPOSITE_COMPONENT_METADATA);
//}
-
+
/**
* Check if the current facelet applied is used to build view metadata.
- *
+ *
* @param context
* @return
*/
@@ -762,7 +762,7 @@ public class FaceletViewDeclarationLangu
{
return context.getAttributes().containsKey(BUILDING_VIEW_METADATA);
}
-
+
public static boolean isRefreshingTransientBuild(FacesContext context)
{
return context.getAttributes().containsKey(REFRESHING_TRANSIENT_BUILD);
@@ -778,18 +778,18 @@ public class FaceletViewDeclarationLangu
//return context.getAttributes().containsKey(MARK_INITIAL_STATE_KEY);
return Boolean.TRUE.equals(context.getAttributes().containsKey(StateManager.IS_BUILDING_INITIAL_STATE));
}
-
+
public static boolean isRefreshTransientBuildOnPSS(FacesContext context)
{
//this include both "true" and "auto"
return context.getAttributes().containsKey(REFRESH_TRANSIENT_BUILD_ON_PSS);
}
-
+
public static boolean isRefreshTransientBuildOnPSSAuto(FacesContext context)
{
return "auto".equalsIgnoreCase((String) context.getAttributes().get(REFRESH_TRANSIENT_BUILD_ON_PSS));
}
-
+
public static boolean isCleanTransientBuildOnRestore(FacesContext context)
{
return context.getAttributes().containsKey(CLEAN_TRANSIENT_BUILD_ON_RESTORE);
@@ -799,12 +799,12 @@ public class FaceletViewDeclarationLangu
{
context.getAttributes().put(CLEAN_TRANSIENT_BUILD_ON_RESTORE, Boolean.TRUE);
}
-
+
public static boolean isUsingPSSOnThisView(FacesContext context)
{
return context.getAttributes().containsKey(USING_PSS_ON_THIS_VIEW);
}
-
+
/**
* In short words, this method take care of "target" an "attached object".
* <ul>
@@ -817,48 +817,48 @@ public class FaceletViewDeclarationLangu
@Override
@SuppressWarnings("unchecked")
public void retargetAttachedObjects(FacesContext context,
- UIComponent topLevelComponent, List<AttachedObjectHandler> handlerList)
+ UIComponent topLevelComponent, List<AttachedObjectHandler> handlerList)
{
checkNull(context, "context");
checkNull(topLevelComponent, "topLevelComponent");
checkNull(handlerList, "handlerList");
-
+
BeanInfo compositeComponentMetadata = (BeanInfo) topLevelComponent.getAttributes().get(UIComponent.BEANINFO_KEY);
-
+
if (compositeComponentMetadata == null)
{
- log.severe("Composite component metadata not found for: "+topLevelComponent.getClientId());
+ log.severe("Composite component metadata not found for: " + topLevelComponent.getClientId());
return;
}
-
+
BeanDescriptor compositeComponentDescriptor = compositeComponentMetadata.getBeanDescriptor();
-
- List<AttachedObjectTarget> targetList = (List<AttachedObjectTarget>)
- compositeComponentDescriptor.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
-
+
+ List<AttachedObjectTarget> targetList = (List<AttachedObjectTarget>)
+ compositeComponentDescriptor.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
+
if (targetList == null || targetList.isEmpty())
{
return;
}
-
+
for (int i = 0, size = handlerList.size(); i < size; i++)
{
AttachedObjectHandler currentHandler = handlerList.get(i);
// In the spec javadoc this variable is referred as forAttributeValue, but
// note it is also called curTargetName
String forValue = currentHandler.getFor();
-
+
for (AttachedObjectTarget currentTarget : targetList)
{
FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance();
-
- if ( ( forValue != null && forValue.equals(currentTarget.getName()) ) &&
- ((currentTarget instanceof ActionSource2AttachedObjectTarget &&
- currentHandler instanceof ActionSource2AttachedObjectHandler) ||
- (currentTarget instanceof EditableValueHolderAttachedObjectTarget &&
- currentHandler instanceof EditableValueHolderAttachedObjectHandler) ||
- (currentTarget instanceof ValueHolderAttachedObjectTarget &&
- currentHandler instanceof ValueHolderAttachedObjectHandler)) )
+
+ if ((forValue != null && forValue.equals(currentTarget.getName())) &&
+ ((currentTarget instanceof ActionSource2AttachedObjectTarget &&
+ currentHandler instanceof ActionSource2AttachedObjectHandler) ||
+ (currentTarget instanceof EditableValueHolderAttachedObjectTarget &&
+ currentHandler instanceof EditableValueHolderAttachedObjectHandler) ||
+ (currentTarget instanceof ValueHolderAttachedObjectTarget &&
+ currentHandler instanceof ValueHolderAttachedObjectHandler)))
{
for (UIComponent component : currentTarget.getTargets(topLevelComponent))
{
@@ -881,27 +881,27 @@ public class FaceletViewDeclarationLangu
// Note that the inner component should have a target with the same name
// as "for" attribute
mctx.addAttachedObjectHandler(component, currentHandler);
-
+
List<AttachedObjectHandler> handlers = mctx.getAttachedObjectHandlers(component);
-
+
retargetAttachedObjects(context, component, handlers);
-
+
handlers.remove(currentHandler);
}
else
{
- currentHandler.applyAttachedObject(context, component);
+ currentHandler.applyAttachedObject(context, component);
}
}
}
- else if ((currentTarget instanceof BehaviorHolderAttachedObjectTarget &&
- currentHandler instanceof BehaviorHolderAttachedObjectHandler))
+ else if ((currentTarget instanceof BehaviorHolderAttachedObjectTarget &&
+ currentHandler instanceof BehaviorHolderAttachedObjectHandler))
{
String eventName = ((BehaviorHolderAttachedObjectHandler) currentHandler).getEventName();
- boolean isDefaultEvent = ((BehaviorHolderAttachedObjectTarget) currentTarget).isDefaultEvent();
-
- if ( (eventName != null && eventName.equals(currentTarget.getName()) ) ||
- (eventName == null && isDefaultEvent) )
+ boolean isDefaultEvent = ((BehaviorHolderAttachedObjectTarget) currentTarget).isDefaultEvent();
+
+ if ((eventName != null && eventName.equals(currentTarget.getName())) ||
+ (eventName == null && isDefaultEvent))
{
List<UIComponent> targets = currentTarget.getTargets(topLevelComponent);
for (int j = 0, targetssize = targets.size(); j < targetssize; j++)
@@ -924,18 +924,18 @@ public class FaceletViewDeclarationLangu
{
mctx.addAttachedObjectHandler(component, currentHandler);
}
-
+
List<AttachedObjectHandler> handlers = mctx.getAttachedObjectHandlers(component);
-
+
retargetAttachedObjects(context, component, handlers);
-
+
handlers.remove(currentHandler);
}
else
{
if (currentHandler instanceof ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper)
{
- currentHandler.applyAttachedObject(context, new ClientBehaviorRedirectEventComponentWrapper(component,
+ currentHandler.applyAttachedObject(context, new ClientBehaviorRedirectEventComponentWrapper(component,
((ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper) currentHandler).getWrappedEventName(), eventName));
}
else
@@ -952,15 +952,15 @@ public class FaceletViewDeclarationLangu
@Override
public void retargetMethodExpressions(FacesContext context,
- UIComponent topLevelComponent)
+ UIComponent topLevelComponent)
{
checkNull(context, "context");
-
+
BeanInfo compositeComponentMetadata = (BeanInfo) topLevelComponent.getAttributes().get(UIComponent.BEANINFO_KEY);
-
+
if (compositeComponentMetadata == null)
{
- log.severe("Composite component metadata not found for: "+topLevelComponent.getClientId());
+ log.severe("Composite component metadata not found for: " + topLevelComponent.getClientId());
return;
}
@@ -971,11 +971,11 @@ public class FaceletViewDeclarationLangu
// only for composite components.
// That means somewhere we need to create a custom BeanInfo object for composite components
// that will be filled somewhere (theorically in ViewDeclarationLanguage.getComponentMetadata())
-
+
PropertyDescriptor[] propertyDescriptors = compositeComponentMetadata.getPropertyDescriptors();
-
+
ELContext elContext = (ELContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
-
+
for (PropertyDescriptor propertyDescriptor : propertyDescriptors)
{
if (propertyDescriptor.getValue("type") != null)
@@ -984,11 +984,11 @@ public class FaceletViewDeclarationLangu
// In that case, "method-signature" is ignored
continue;
}
-
+
String attributeName = propertyDescriptor.getName();
//boolean isKnownMethod = "action".equals(attributeName) || "actionListener".equals(attributeName)
// || "validator".equals(attributeName) || "valueChangeListener".equals(attributeName);
-
+
// <composite:attribute> method-signature attribute is
// ValueExpression that must evaluate to String
ValueExpression methodSignatureExpression
@@ -1000,9 +1000,9 @@ public class FaceletViewDeclarationLangu
// Note that it could be null, so in that case we don't have to do anything
methodSignature = (String) methodSignatureExpression.getValue(elContext);
}
-
+
String targetAttributeName = null;
- ValueExpression targetAttributeNameVE = (ValueExpression)propertyDescriptor.getValue("targetAttributeName");
+ ValueExpression targetAttributeNameVE = (ValueExpression) propertyDescriptor.getValue("targetAttributeName");
if (targetAttributeNameVE != null)
{
targetAttributeName = (String) targetAttributeNameVE.getValue(context.getELContext());
@@ -1015,16 +1015,16 @@ public class FaceletViewDeclarationLangu
{
targetAttributeName = attributeName;
}
-
- boolean isKnownTargetAttributeMethod = "action".equals(targetAttributeName) || "actionListener".equals(targetAttributeName)
- || "validator".equals(targetAttributeName) || "valueChangeListener".equals(targetAttributeName);
-
+
+ boolean isKnownTargetAttributeMethod = "action".equals(targetAttributeName) || "actionListener".equals(targetAttributeName)
+ || "validator".equals(targetAttributeName) || "valueChangeListener".equals(targetAttributeName);
+
// either the attributeName has to be a knownMethod or there has to be a method-signature
if (isKnownTargetAttributeMethod || methodSignature != null)
{
- ValueExpression targetsExpression =
- (ValueExpression) propertyDescriptor.getValue("targets");
-
+ ValueExpression targetsExpression =
+ (ValueExpression) propertyDescriptor.getValue("targets");
+
String targets = null;
// <composite:attribute> targets attribute is
// ValueExpression that must evaluate to String
@@ -1032,12 +1032,12 @@ public class FaceletViewDeclarationLangu
{
targets = (String) targetsExpression.getValue(elContext);
}
-
+
if (targets == null)
{
// "...let the name of the metadata element be the
// evaluated value of the targets attribute..."
- targets = attributeName;
+ targets = attributeName;
}
FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance();
@@ -1048,9 +1048,9 @@ public class FaceletViewDeclarationLangu
if (!mctx.isMethodExpressionAttributeApplied(topLevelComponent, attributeName))
{
- ValueExpression attributeNameValueExpression =
- (ValueExpression) topLevelComponent.getAttributes().get(attributeName);
-
+ ValueExpression attributeNameValueExpression =
+ (ValueExpression) topLevelComponent.getAttributes().get(attributeName);
+
if (attributeNameValueExpression == null)
{
// composite:attribute has a default property, so if we can't found on the
@@ -1063,7 +1063,7 @@ public class FaceletViewDeclarationLangu
ValueExpression ve = (ValueExpression) propertyDescriptor.getValue("required");
if (ve != null)
{
- Object requiredValue = ve.getValue (elContext);
+ Object requiredValue = ve.getValue(elContext);
Boolean required = null;
if (requiredValue instanceof Boolean)
{
@@ -1073,7 +1073,7 @@ public class FaceletViewDeclarationLangu
{
required = Boolean.getBoolean(requiredValue.toString());
}
-
+
if (required != null && required.booleanValue())
{
if (log.isLoggable(Level.SEVERE))
@@ -1086,17 +1086,17 @@ public class FaceletViewDeclarationLangu
continue;
}
}
-
- String [] targetsArray = StringUtils.splitShortString(targets, ' ');
+
+ String[] targetsArray = StringUtils.splitShortString(targets, ' ');
String attributeExpressionString = attributeNameValueExpression.getExpressionString();
MethodExpression methodExpression = null;
MethodExpression methodExpression2 = null;
//Check if the stored valueExpression is a ccRedirection, to handle it properly later.
- boolean ccAttrMeRedirection =
+ boolean ccAttrMeRedirection =
attributeNameValueExpression instanceof LocationValueExpression &&
- CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
- attributeNameValueExpression.getExpressionString());
+ CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
+ attributeNameValueExpression.getExpressionString());
if (isKnownTargetAttributeMethod)
{
@@ -1127,11 +1127,11 @@ public class FaceletViewDeclarationLangu
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);
-
+
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
- createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
+ createMethodExpression(elContext,
+ attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+
//Store the method expression to the topLevelComponent to allow reference it through EL
if (!ccAttrMeRedirection)
{
@@ -1145,9 +1145,9 @@ public class FaceletViewDeclarationLangu
// target is EditableValueHolder
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
- VALIDATOR_SIGNATURE), attributeNameValueExpression);
-
+ attributeExpressionString, Void.TYPE,
+ VALIDATOR_SIGNATURE), attributeNameValueExpression);
+
//Store the method expression to the topLevelComponent to allow reference it through EL
if (!ccAttrMeRedirection)
{
@@ -1161,12 +1161,12 @@ public class FaceletViewDeclarationLangu
// target is EditableValueHolder
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
+ attributeExpressionString, Void.TYPE,
VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
+ attributeExpressionString, Void.TYPE,
EMPTY_CLASS_ARRAY), attributeNameValueExpression);
//Store the method expression to the topLevelComponent to allow reference it through EL
@@ -1177,26 +1177,26 @@ public class FaceletViewDeclarationLangu
}
// Otherwise keep the current ValueExpression, because it will be used chain other value expressions
}
-
+
UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
for (String target : targetsArray)
{
UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
-
+
if (innerComponent == null)
{
//if (log.isLoggable(Level.SEVERE))
// log.severe("Inner component " + target + " not found when retargetMethodExpressions");
continue;
}
-
+
if (isCompositeComponentRetarget(context, innerComponent, targetAttributeName))
{
innerComponent.getAttributes().put(targetAttributeName, attributeNameValueExpression);
-
+
mctx.clearMethodExpressionAttribute(innerComponent, targetAttributeName);
-
+
retargetMethodExpressions(context, innerComponent);
}
else
@@ -1207,15 +1207,15 @@ public class FaceletViewDeclarationLangu
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
+
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection)
{
- ((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
+ ((ActionSource2) innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
}
else
{
- ((ActionSource2)innerComponent).setActionExpression(methodExpression);
+ ((ActionSource2) innerComponent).setActionExpression(methodExpression);
}
}
else if ("actionListener".equals(targetAttributeName))
@@ -1224,9 +1224,9 @@ public class FaceletViewDeclarationLangu
ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
if (o != null)
{
- ((ActionSource2)innerComponent).removeActionListener(o);
+ ((ActionSource2) innerComponent).removeActionListener(o);
}
-
+
// target is ActionSource2
ActionListener actionListener = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
@@ -1241,23 +1241,23 @@ public class FaceletViewDeclarationLangu
attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
- createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+ createMethodExpression(elContext,
+ attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
}
- ((ActionSource2)innerComponent).addActionListener(actionListener);
+ ((ActionSource2) innerComponent).addActionListener(actionListener);
mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
}
else if ("validator".equals(targetAttributeName))
{
- //First try to remove any prevous target if any
+ //First try to remove any prevous target if any
Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
if (o != null)
{
- ((EditableValueHolder)innerComponent).removeValidator(o);
+ ((EditableValueHolder) innerComponent).removeValidator(o);
}
-
+
// target is EditableValueHolder
Validator validator = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
@@ -1269,12 +1269,12 @@ public class FaceletViewDeclarationLangu
{
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
- VALIDATOR_SIGNATURE), attributeNameValueExpression);
-
- validator = new MethodExpressionValidator(methodExpression);
+ attributeExpressionString, Void.TYPE,
+ VALIDATOR_SIGNATURE), attributeNameValueExpression);
+
+ validator = new MethodExpressionValidator(methodExpression);
}
- ((EditableValueHolder)innerComponent).addValidator( validator );
+ ((EditableValueHolder) innerComponent).addValidator(validator);
mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, validator);
}
else if ("valueChangeListener".equals(targetAttributeName))
@@ -1282,9 +1282,9 @@ public class FaceletViewDeclarationLangu
ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
if (o != null)
{
- ((EditableValueHolder)innerComponent).removeValueChangeListener(o);
+ ((EditableValueHolder) innerComponent).removeValueChangeListener(o);
}
-
+
// target is EditableValueHolder
ValueChangeListener valueChangeListener = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
@@ -1296,17 +1296,17 @@ public class FaceletViewDeclarationLangu
{
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
+ attributeExpressionString, Void.TYPE,
VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
-
+
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, Void.TYPE,
+ attributeExpressionString, Void.TYPE,
EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
+
valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
}
- ((EditableValueHolder)innerComponent).addValueChangeListener( valueChangeListener );
+ ((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, valueChangeListener);
}
}
@@ -1323,30 +1323,30 @@ public class FaceletViewDeclarationLangu
methodSignature = methodSignature.trim();
methodExpression = context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
- attributeExpressionString, _getReturnType(methodSignature),
+ attributeExpressionString, _getReturnType(methodSignature),
_getParameters(methodSignature));
-
+
methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);
-
+
UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
-
+
for (String target : targetsArray)
{
UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
-
+
if (innerComponent == null)
{
continue;
}
-
+
// If a component is found, that means the expression should be retarget to the
// components related
if (isCompositeComponentRetarget(context, innerComponent, targetAttributeName))
{
innerComponent.getAttributes().put(targetAttributeName, attributeNameValueExpression);
-
+
mctx.clearMethodExpressionAttribute(innerComponent, targetAttributeName);
-
+
retargetMethodExpressions(context, innerComponent);
}
else
@@ -1374,24 +1374,24 @@ public class FaceletViewDeclarationLangu
}
mctx.markMethodExpressionAttribute(topLevelComponent, attributeName);
}
-
+
// We need to remove the previous ValueExpression, to prevent some possible
// confusion when the same value is retrieved from the attribute map.
topLevelComponent.setValueExpression(attributeName, null);
}
}
}
-
+
private boolean isCompositeComponentRetarget(FacesContext context, UIComponent component, String attributeName)
{
if (UIComponent.isCompositeComponent(component))
{
BeanInfo compositeComponentMetadata = (BeanInfo) component.getAttributes().get(UIComponent.BEANINFO_KEY);
-
+
PropertyDescriptor[] propertyDescriptors = compositeComponentMetadata.getPropertyDescriptors();
-
+
ELContext elContext = (ELContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
-
+
for (PropertyDescriptor propertyDescriptor : propertyDescriptors)
{
if (propertyDescriptor.getValue("type") != null)
@@ -1405,7 +1405,7 @@ public class FaceletViewDeclarationLangu
{
//boolean isKnownMethod = "action".equals(attributeName) || "actionListener".equals(attributeName)
//|| "validator".equals(attributeName) || "valueChangeListener".equals(attributeName);
-
+
// <composite:attribute> method-signature attribute is
// ValueExpression that must evaluate to String
ValueExpression methodSignatureExpression
@@ -1417,9 +1417,9 @@ public class FaceletViewDeclarationLangu
// Note that it could be null, so in that case we don't have to do anything
methodSignature = (String) methodSignatureExpression.getValue(elContext);
}
-
+
String targetAttributeName = null;
- ValueExpression targetAttributeNameVE = (ValueExpression)propertyDescriptor.getValue("targetAttributeName");
+ ValueExpression targetAttributeNameVE = (ValueExpression) propertyDescriptor.getValue("targetAttributeName");
if (targetAttributeNameVE != null)
{
targetAttributeName = (String) targetAttributeNameVE.getValue(context.getELContext());
@@ -1432,10 +1432,10 @@ public class FaceletViewDeclarationLangu
{
targetAttributeName = attributeName;
}
-
- boolean isKnownTargetAttributeMethod = "action".equals(targetAttributeName) || "actionListener".equals(targetAttributeName)
- || "validator".equals(targetAttributeName) || "valueChangeListener".equals(targetAttributeName);
-
+
+ boolean isKnownTargetAttributeMethod = "action".equals(targetAttributeName) || "actionListener".equals(targetAttributeName)
+ || "validator".equals(targetAttributeName) || "valueChangeListener".equals(targetAttributeName);
+
// either the attributeName has to be a knownMethod or there has to be a method-signature
if (isKnownTargetAttributeMethod || methodSignature != null)
{
@@ -1476,33 +1476,33 @@ public class FaceletViewDeclarationLangu
if (originalValueExpression instanceof LocationValueExpression)
{
return new LocationMethodExpression(
- ((LocationValueExpression)originalValueExpression).getLocation(),
- reWrapMethodExpression(createdMethodExpression,
- ((LocationValueExpression)originalValueExpression).getWrapped()));
+ ((LocationValueExpression) originalValueExpression).getLocation(),
+ reWrapMethodExpression(createdMethodExpression,
+ ((LocationValueExpression) originalValueExpression).getWrapped()));
}
- else if (originalValueExpression instanceof FacesWrapper &&
- ((FacesWrapper)originalValueExpression).getWrapped() instanceof ValueExpression)
+ else if (originalValueExpression instanceof FacesWrapper &&
+ ((FacesWrapper) originalValueExpression).getWrapped() instanceof ValueExpression)
{
- return reWrapMethodExpression(createdMethodExpression,
- (ValueExpression) ((FacesWrapper)originalValueExpression).getWrapped());
+ return reWrapMethodExpression(createdMethodExpression,
+ (ValueExpression) ((FacesWrapper) originalValueExpression).getWrapped());
}
else
{
return createdMethodExpression;
}
}
-
+
/**
* This method is similar to shared ClassUtils.javaTypeToClass,
* but the default package is java.lang
* TODO: Move to shared project
- *
+ *
* @param type
* @return
* @throws ClassNotFoundException
*/
public static Class _javaTypeToClass(String type)
- throws ClassNotFoundException
+ throws ClassNotFoundException
{
if (type == null)
{
@@ -1526,11 +1526,11 @@ public class FaceletViewDeclarationLangu
if (type.indexOf('.') == -1)
{
- type = "java.lang."+type;
+ type = "java.lang." + type;
}
return ClassUtils.classForName(type);
}
-
+
private Class _getReturnType(String signature)
{
int endName = signature.indexOf('(');
@@ -1545,17 +1545,17 @@ public class FaceletViewDeclarationLangu
}
try
{
- return _javaTypeToClass(signature.substring(0,end));
+ return _javaTypeToClass(signature.substring(0, end));
}
- catch(ClassNotFoundException e)
+ catch (ClassNotFoundException e)
{
- throw new FacesException("Invalid method signature:"+signature);
+ throw new FacesException("Invalid method signature:" + signature);
}
}
/**
* Get the parameters types from the function signature.
- *
+ *
* @return An array of parameter class names
*/
private Class[] _getParameters(String signature) throws FacesException
@@ -1574,20 +1574,20 @@ public class FaceletViewDeclarationLangu
p = signature.indexOf(')', start);
if (p < 0)
{
- throw new FacesException("Invalid method signature:"+signature);
+ throw new FacesException("Invalid method signature:" + signature);
}
lastArg = true;
}
String arg = signature.substring(start, p).trim();
if (!"".equals(arg))
{
- try
+ try
{
params.add(_javaTypeToClass(arg));
}
- catch(ClassNotFoundException e)
+ catch (ClassNotFoundException e)
{
- throw new FacesException("Invalid method signature:"+signature);
+ throw new FacesException("Invalid method signature:" + signature);
}
}
if (lastArg)
@@ -1623,7 +1623,7 @@ public class FaceletViewDeclarationLangu
{
_stateMgmtStrategy = new DefaultFaceletsStateManagementStrategy();
}
-
+
return _usePartialStateSavingOnThisView(viewId) ? _stateMgmtStrategy : null;
}
@@ -1697,7 +1697,7 @@ public class FaceletViewDeclarationLangu
//{
// extContext.getSession(true);
//}
-
+
// render the view to the response
writer.startDocument();
@@ -1722,7 +1722,7 @@ public class FaceletViewDeclarationLangu
// Writer or OutputStream; it simply clears any values buffered by this
// ResponseWriter. ..."
writer.flush();
-
+
// =-= markoc: STATE_KEY is in output ONLY if
// stateManager.isSavingStateInClient(context)is true - see
// org.apache.myfaces.application.ViewHandlerImpl.writeState(FacesContext)
@@ -1795,7 +1795,7 @@ public class FaceletViewDeclarationLangu
handleRenderException(context, e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -1835,17 +1835,17 @@ public class FaceletViewDeclarationLangu
//{
// return new UIViewRoot();
//}
-
+
//else if (!_buildBeforeRestore)
//{
- return super.restoreView(context, viewId);
+ return super.restoreView(context, viewId);
//}
//else
//{
- // TODO: VALIDATE - Is _buildBeforeRestore relevant at all for 2.0? -= SL =-
- // ANS: buildBeforeRestore evolved to partial state saving, so this logic
- // is now on StateManagerStrategy implementation -= Leo U =-
- /*
+ // TODO: VALIDATE - Is _buildBeforeRestore relevant at all for 2.0? -= SL =-
+ // ANS: buildBeforeRestore evolved to partial state saving, so this logic
+ // is now on StateManagerStrategy implementation -= Leo U =-
+ /*
UIViewRoot viewRoot = createView(context, viewId);
context.setViewRoot(viewRoot);
@@ -1888,37 +1888,37 @@ public class FaceletViewDeclarationLangu
/**
* Creates the Facelet page compiler.
- *
+ *
* @param context
* the current FacesContext
- *
+ *
* @return the application's Facelet page compiler
*/
protected Compiler createCompiler(FacesContext context)
{
Compiler compiler = new SAXCompiler();
-
+
compiler.setDevelopmentProjectStage(context.isProjectStage(ProjectStage.Development));
loadLibraries(context, compiler);
loadDecorators(context, compiler);
loadOptions(context, compiler);
-
+
compiler.setFaceletsProcessingConfigurations(
RuntimeConfig.getCurrentInstance(
- context.getExternalContext()).getFaceletProcessingConfigurations());
+ context.getExternalContext()).getFaceletProcessingConfigurations());
return compiler;
}
/**
* Creates a FaceletFactory instance using the specified compiler.
- *
+ *
* @param context
* the current FacesContext
* @param compiler
* the compiler to be used by the factory
- *
+ *
* @return the factory used by this VDL to load pages
*/
protected FaceletFactory createFaceletFactory(FacesContext context, Compiler compiler)
@@ -1927,7 +1927,7 @@ public class FaceletViewDeclarationLangu
// refresh period
long refreshPeriod;
- if(context.isProjectStage(ProjectStage.Production))
+ if (context.isProjectStage(ProjectStage.Production))
{
refreshPeriod = WebConfigParamUtils.getLongInitParameter(eContext, PARAMS_REFRESH_PERIOD, DEFAULT_REFRESH_PERIOD_PRODUCTION);
}
@@ -1935,7 +1935,7 @@ public class FaceletViewDeclarationLangu
{
refreshPeriod = WebConfigParamUtils.getLongInitParameter(eContext, PARAMS_REFRESH_PERIOD, DEFAULT_REFRESH_PERIOD);
}
-
+
// resource resolver
ResourceResolver resolver = new DefaultResourceResolver();
String faceletsResourceResolverClassName = WebConfigParamUtils.getStringInitParameter(eContext, PARAMS_RESOURCE_RESOLVER, null);
@@ -1947,10 +1947,10 @@ public class FaceletViewDeclarationLangu
}
_resourceResolver = resolver;
-
+
return new DefaultFaceletFactory(compiler, resolver, refreshPeriod);
}
-
+
protected ResponseWriter createResponseWriter(FacesContext context) throws IOException, FacesException
{
@@ -1979,7 +1979,7 @@ public class FaceletViewDeclarationLangu
// -= Leonardo Uribe =- Add */* to the contentType is a fix done from FaceletViewHandler
// to make old RI versions work, but since this is for JSF 2.0 it is not necessary that code.
ResponseWriter writer = renderKit.createResponseWriter(NullWriter.Instance, contentType, encoding);
-
+
//ResponseWriter writer;
// append */* to the contentType so createResponseWriter will succeed no matter
// the requested contentType.
@@ -1996,10 +1996,10 @@ public class FaceletViewDeclarationLangu
//}
// catch (IllegalArgumentException e)
//{
- // Added because of an RI bug prior to 1.2_05-b3. Might as well leave it in case other
- // impls have the same problem. https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=613
- //log.finest("The impl didn't correctly handled '*/*' in the content type list. Trying '*/*' directly.");
- //writer = renderKit.createResponseWriter(NullWriter.Instance, "*/*", encoding);
+ // Added because of an RI bug prior to 1.2_05-b3. Might as well leave it in case other
+ // impls have the same problem. https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=613
+ //log.finest("The impl didn't correctly handled '*/*' in the content type list. Trying '*/*' directly.");
+ //writer = renderKit.createResponseWriter(NullWriter.Instance, "*/*", encoding);
//}
// Override the JSF provided content type if necessary
@@ -2037,7 +2037,7 @@ public class FaceletViewDeclarationLangu
}
/**
- * @deprecated
+ * @deprecated
*/
@Deprecated
protected String getRenderedViewId(FacesContext context, String actionId)
@@ -2050,7 +2050,7 @@ public class FaceletViewDeclarationLangu
/**
* Generate the content type
- *
+ *
* @param context
* @param orig
* @return
@@ -2082,7 +2082,7 @@ public class FaceletViewDeclarationLangu
/**
* Generate the encoding
- *
+ *
* @param context
* @param orig
* @return
@@ -2103,7 +2103,7 @@ public class FaceletViewDeclarationLangu
{
log.finest("Facelet specified alternate encoding '" + encoding + "'");
}
-
+
sm.put(CHARACTER_ENCODING_KEY, encoding);
}
@@ -2145,7 +2145,7 @@ public class FaceletViewDeclarationLangu
}
- protected void handleRenderException(FacesContext context, Exception e)
+ protected void handleRenderException(FacesContext context, Exception e)
throws IOException, ELException, FacesException
{
/*
@@ -2161,7 +2161,7 @@ public class FaceletViewDeclarationLangu
log.log(Level.SEVERE, sb.toString(), e);
*/
-
+
// rethrow the Exception to be handled by the ExceptionHandler
if (e instanceof RuntimeException)
{
@@ -2197,7 +2197,7 @@ public class FaceletViewDeclarationLangu
/**
* Load the various decorators for Facelets.
- *
+ *
* @param context
* the current FacesContext
* @param compiler
@@ -2228,7 +2228,7 @@ public class FaceletViewDeclarationLangu
/**
* Load the various tag libraries for Facelets.
- *
+ *
* @param context
* the current FacesContext
* @param compiler
@@ -2237,7 +2237,7 @@ public class FaceletViewDeclarationLangu
protected void loadLibraries(FacesContext context, Compiler compiler)
{
ExternalContext eContext = context.getExternalContext();
-
+
compiler.addTagLibrary(new CoreLibrary());
compiler.addTagLibrary(new HtmlLibrary());
compiler.addTagLibrary(new UILibrary());
@@ -2279,7 +2279,7 @@ public class FaceletViewDeclarationLangu
/**
* Load the various options for Facelets compiler. Currently only comment skipping is supported.
- *
+ *
* @param context
* the current FacesContext
* @param compiler
@@ -2312,12 +2312,12 @@ public class FaceletViewDeclarationLangu
/**
* Gets the Facelet representing the specified view identifier.
- *
+ *
* @param viewId
* the view identifier
- *
+ *
* @return the Facelet representing the specified view identifier
- *
+ *
* @throws IOException
* if a read or parsing error occurs
*/
@@ -2334,7 +2334,7 @@ public class FaceletViewDeclarationLangu
FaceletFactory.setInstance(null);
}
}
-
+
private Facelet _getViewMetadataFacelet(String viewId) throws IOException
{
// grab our FaceletFactory and create a Facelet used to create view metadata
@@ -2350,7 +2350,6 @@ public class FaceletViewDeclarationLangu
}
-
private void _initializeBuffer(ExternalContext context)
{
_bufferSize = WebConfigParamUtils.getIntegerInitParameter(context, PARAMS_BUFFER_SIZE, -1);
@@ -2360,20 +2359,20 @@ public class FaceletViewDeclarationLangu
{
String facesVersion = RuntimeConfig.getCurrentInstance(context).getFacesVersion();
boolean partialStateSavingDefault;
-
+
// Per spec section 11.1.3, the default value for the partial state saving feature needs
// to be true if 2.0, false otherwise.
-
+
partialStateSavingDefault = "2.0".equals(facesVersion) || "2.1".equals(facesVersion);
-
+
// In jsf 2.0 this code evolve as PartialStateSaving feature
//_buildBeforeRestore = _getBooleanParameter(context, PARAM_BUILD_BEFORE_RESTORE, false);
- _partialStateSaving = WebConfigParamUtils.getBooleanInitParameter(context,
+ _partialStateSaving = WebConfigParamUtils.getBooleanInitParameter(context,
StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, partialStateSavingDefault);
-
- String [] viewIds = StringUtils.splitShortString(WebConfigParamUtils.getStringInitParameter(context,
+
+ String[] viewIds = StringUtils.splitShortString(WebConfigParamUtils.getStringInitParameter(context,
StateManager.FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME), ',');
-
+
if (viewIds.length > 0)
{
_viewIds = new HashSet<String>(viewIds.length, 1.0f);
@@ -2383,7 +2382,7 @@ public class FaceletViewDeclarationLangu
{
_viewIds = null;
}
-
+
if (_partialStateSaving)
{
_refreshTransientBuildOnPSS = MyfacesConfig.getCurrentInstance(context).isRefreshTransientBuildOnPSS();
@@ -2391,17 +2390,17 @@ public class FaceletViewDeclarationLangu
_markInitialStateWhenApplyBuildView = WebConfigParamUtils.getBooleanInitParameter(context, PARAM_MARK_INITIAL_STATE_WHEN_APPLY_BUILD_VIEW, false);
}
}
-
+
private boolean _usePartialStateSavingOnThisView(String viewId)
{
- return _partialStateSaving && !(_viewIds != null && _viewIds.contains(viewId) );
+ return _partialStateSaving && !(_viewIds != null && _viewIds.contains(viewId));
}
-
+
private class FaceletViewMetadata extends ViewMetadataBase
{
/**
* Constructor
- *
+ *
* Note that this viewId is not the one after calculateViewId() method
*/
public FaceletViewMetadata(String viewId)
@@ -2418,14 +2417,14 @@ public class FaceletViewDeclarationLangu
try
{
context.setProcessingEvents(false);
-
+
// spec doesn't say that this is necessary, but we blow up later if
// the viewroot isn't available from the FacesContext.
// -= Leonardo Uribe =- since it is supposed when we apply view metadata
// facelet we don't apply components with renderers and we don't call getRenderKit()
// it is safe to let this one commented
// context.setViewRoot(view);
-
+
// -= Leonardo Uribe =- This part is related to section 2.5.5 of jsf 2.0 spec.
// In theory what we need here is fill UIViewRoot.METADATA_FACET_NAME facet
// with UIViewParameter instances. Later, ViewHandlerImpl.getBookmarkableURL(),
@@ -2437,7 +2436,7 @@ public class FaceletViewDeclarationLangu
// UIViewParameter instances should be taken into account.
// It should be an additional call to buildView on Render Response phase.
// buildView(context, view);
-
+
context.getAttributes().put(BUILDING_VIEW_METADATA, Boolean.TRUE);
// we have to invoke createView() on the application's ViewHandler
@@ -2445,7 +2444,7 @@ public class FaceletViewDeclarationLangu
// the ViewHandler might be wrapped and wants to do some work
// in createView() (e.g. in Trinidad - see MYFACES-2641)
UIViewRoot view = context.getApplication().getViewHandler().createView(context, getViewId());
-
+
if (view != null)
{
// inside createView(context,viewId), calculateViewId() is called and
@@ -2464,7 +2463,7 @@ public class FaceletViewDeclarationLangu
finally
{
context.getAttributes().remove(BUILDING_VIEW_METADATA);
-
+
context.setProcessingEvents(true);
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java?rev=1188631&r1=1188630&r2=1188631&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java Tue Oct 25 12:33:10 2011
@@ -194,10 +194,12 @@ public class StartupServletContextListen
* @param event
* @param operation
*/
- private void dispatchInitializationEvent(ServletContextEvent event, int operation) {
+ private void dispatchInitializationEvent(ServletContextEvent event, int operation)
+ {
String [] pluginEntries = (String []) _servletContext.getAttribute(FACES_INIT_PLUGINS);
- if(pluginEntries == null) {
+ if(pluginEntries == null)
+ {
String plugins = (String) _servletContext.getInitParameter(FACES_INIT_PLUGINS);
if(plugins == null)
{
@@ -209,7 +211,8 @@ public class StartupServletContextListen
}
//now we process the plugins
- for(String plugin: pluginEntries) {
+ for(String plugin: pluginEntries)
+ {
log.info("Processing plugin:"+plugin);
try {
//for now the initializers have to be stateless to
@@ -222,7 +225,8 @@ public class StartupServletContextListen
}
StartupListener initializer = (StartupListener) pluginClass.newInstance();
- switch(operation) {
+ switch(operation)
+ {
case FACES_INIT_PHASE_PREINIT:
initializer.preInit(event);
break;
@@ -238,11 +242,17 @@ public class StartupServletContextListen
}
- } catch (ClassNotFoundException e) {
+ }
+ catch (ClassNotFoundException e)
+ {
log.log(Level.SEVERE, e.getMessage(), e);
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e)
+ {
log.log(Level.SEVERE, e.getMessage(), e);
- } catch (InstantiationException e) {
+ }
+ catch (InstantiationException e)
+ {
log.log(Level.SEVERE, e.getMessage(), e);
}