in impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java [74:228]
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
ELException
{
FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
boolean processed = false;
//assign an unique id for this section
AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
String uniqueId = actx.generateUniqueFaceletTagId(fcc.startComponentUniqueIdSection(), tagId);
Integer savedOption = null;
try
{
Integer restoredSavedOption = getSavedOption(ctx, fcc, parent, uniqueId);
if (restoredSavedOption != null)
{
if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
{
for (int i = 0; i < this.when.length; i++)
{
//Ensure each option has its unique section
fcc.startComponentUniqueIdSection();
try
{
if (!processed)
{
if (this.when[i].isTestTrue(ctx))
{
boolean markInitialState = !restoredSavedOption.equals(i);
boolean oldMarkInitialState = false;
Boolean isBuildingInitialState = null;
try
{
if (markInitialState)
{
//set markInitialState flag
oldMarkInitialState = fcc.isMarkInitialState();
fcc.setMarkInitialState(true);
isBuildingInitialState = (Boolean) ctx.getFacesContext().
getAttributes().put(
StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
}
this.when[i].apply(ctx, parent);
}
finally
{
if (markInitialState)
{
//unset markInitialState flag
if (isBuildingInitialState == null)
{
ctx.getFacesContext().getAttributes().remove(
StateManager.IS_BUILDING_INITIAL_STATE);
}
else
{
ctx.getFacesContext().getAttributes().put(
StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
}
fcc.setMarkInitialState(oldMarkInitialState);
}
}
processed = true;
savedOption = i;
}
}
}
finally
{
fcc.endComponentUniqueIdSection();
}
}
}
else
{
for (int i = 0; i < this.when.length; i++)
{
//Ensure each option has its unique section
fcc.startComponentUniqueIdSection();
try
{
if (!processed)
{
if (restoredSavedOption.equals(i))
{
this.when[i].apply(ctx, parent);
processed = true;
savedOption = i;
}
}
}
finally
{
fcc.endComponentUniqueIdSection();
}
}
}
}
else
{
for (int i = 0; i < this.when.length; i++)
{
//Ensure each option has its unique section
fcc.startComponentUniqueIdSection();
try
{
if (!processed)
{
if (this.when[i].isTestTrue(ctx))
{
this.when[i].apply(ctx, parent);
processed = true;
savedOption = i;
}
}
}
finally
{
fcc.endComponentUniqueIdSection();
}
}
}
if (this.otherwise != null)
{
fcc.startComponentUniqueIdSection();
try
{
if (!processed)
{
this.otherwise.apply(ctx, parent);
savedOption = -1;
}
}
finally
{
fcc.endComponentUniqueIdSection();
}
}
}
finally
{
fcc.endComponentUniqueIdSection();
}
ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, savedOption);
if (fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() && !fcc.isRefreshingTransientBuild())
{
//Mark the parent component to be saved and restored fully.
ComponentSupport.markComponentToRestoreFully(ctx.getFacesContext(), parent);
}
if (fcc.isDynamicComponentSection())
{
ComponentSupport.markComponentToRefreshDynamically(ctx.getFacesContext(), parent);
}
}