Skip to content

Commit

Permalink
resetValues should not carry EXECUTE_LIFECYCLE visit hint
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Feb 17, 2024
1 parent 2b30a2c commit 82f8a9c
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter.PARTIAL_RENDER_PARAM;
import static com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter.PARTIAL_RESET_VALUES_PARAM;
import static jakarta.faces.FactoryFinder.VISIT_CONTEXT_FACTORY;
import static jakarta.faces.component.visit.VisitHint.EXECUTE_LIFECYCLE;
import static jakarta.faces.component.visit.VisitHint.SKIP_UNRENDERED;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;

Expand All @@ -31,6 +33,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -69,6 +72,11 @@ public class PartialViewContextImpl extends PartialViewContext {
// Log instance for this class
private static Logger LOGGER = FacesLogger.CONTEXT.getLogger();

private static final Set<VisitHint> SKIP_UNRENDERED_HINT = EnumSet.of(SKIP_UNRENDERED);

private static final Set<VisitHint> SKIP_UNRENDERED_AND_EXECUTE_LIFECYCLE_HINTS = EnumSet.of(SKIP_UNRENDERED, EXECUTE_LIFECYCLE);


private boolean released;

// BE SURE TO ADD NEW IVARS TO THE RELEASE METHOD
Expand Down Expand Up @@ -381,7 +389,7 @@ private void processComponents(UIComponent component, PhaseId phaseId, Collectio
// process. Create our (partial) VisitContext and the
// VisitCallback that will be invoked for each component that
// is visited.
VisitContext visitContext = createPartialVisitContext(context, phaseClientIds);
VisitContext visitContext = createPartialVisitContext(context, phaseClientIds, true);
PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId);
component.visitTree(visitContext, visitCallback);

Expand All @@ -398,11 +406,11 @@ private void processComponents(UIComponent component, PhaseId phaseId, Collectio
}
}

private static VisitContext createPartialVisitContext(FacesContext context, Collection<String> clientIds) {
private static VisitContext createPartialVisitContext(FacesContext context, Collection<String> clientIds, boolean executeLifecycle) {

// Note that we use the SKIP_UNRENDERED hint as
// we only want to visit the rendered subtree.
EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED, VisitHint.EXECUTE_LIFECYCLE);
Set<VisitHint> hints = executeLifecycle ? SKIP_UNRENDERED_AND_EXECUTE_LIFECYCLE_HINTS : SKIP_UNRENDERED_HINT;
VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY);
return visitContextFactory.getVisitContext(context, clientIds, hints);
}
Expand All @@ -412,7 +420,7 @@ private static void resetValues(UIComponent component, Collection<String> client
// NOTE: this is indeed a copy of the one in UIViewRoot#resetValues().
// The difference is that we want to be able to control the visit hints.
// This isn't possible via the UIViewRoot#resetValues() API in its current form.
component.visitTree(createPartialVisitContext(context, clientIds), new DoResetValues());
component.visitTree(createPartialVisitContext(context, clientIds, false), new DoResetValues());
}

private static class DoResetValues implements VisitCallback {
Expand Down

0 comments on commit 82f8a9c

Please sign in to comment.