}
}
else
{
// Per the spec: build the view.
ViewDeclarationLanguage vdl = _vdlFactory.getViewDeclarationLanguage(viewId);
Object faceletViewState = null;
try
{
ViewMetadata metadata = vdl.getViewMetadata (context, viewId);
Collection<UIViewParameter> viewParameters = null;
if (metadata != null)
{
view = metadata.createMetadataView(context);
if (view != null)
{
viewParameters = metadata.getViewParameters(view);
}
}
if (view == null)
{
view = context.getApplication().getViewHandler().createView(context, viewId);
}
context.setViewRoot (view);
if (state != null && state[1] != null)
{
states = (Map<String, Object>) state[1];
faceletViewState = UIComponentBase.restoreAttachedState(
context,states.get(ComponentSupport.FACELET_STATE_INSTANCE));
if (faceletViewState != null)
{
view.getAttributes().put(ComponentSupport.FACELET_STATE_INSTANCE, faceletViewState);
}
if (state.length == 3)
{
if (view.getId() == null)
{
view.setId(view.createUniqueId(context, null));
}
//Jump to where the count is
view.getAttributes().put(UNIQUE_ID_COUNTER_KEY, state[2]);
}
}
// TODO: Why is necessary enable event processing?
// ANS: On RestoreViewExecutor, setProcessingEvents is called first to false
// and then to true when postback. Since we need listeners registered to PostAddToViewEvent
// event to be handled, we should enable it again. We are waiting a response from EG about
// the behavior of those listeners, because for partial state saving we need this listeners
// be called from here and relocate components properly, but for now we have to let this code as is.
try
{
context.setProcessingEvents (true);
vdl.buildView (context, view);
// In the latest code related to PostAddToView, it is
// triggered no matter if it is applied on postback. It seems that MYFACES-2389,
// TRINIDAD-1670 and TRINIDAD-1671 are related.
// This code is no longer necessary, but better let it here.
//_publishPostBuildComponentTreeOnRestoreViewEvent(context, view);