public static VisitContext createVisitContext(FacesContext context) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, null, null); }
public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
/** * <p>Returns a VisitContext instance that is initialized with the * specified ids and hintsfor use with {@link * UIComponent#visitTree}.</p> * * @param context the FacesContext for the current request * @param ids the client ids of the components to visit. If null, * all components will be visited. * @param hints the VisitHints to apply to the visit. If * <code>null</code>, no hints are applied. * @return a VisitContext instance that is initialized with the * specified ids and hints. */ public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) { VisitContextFactory factory = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY); return factory.getVisitContext(context, ids, hints); }
@Override public VisitContext getVisitContext(FacesContext facesContext, Collection<String> ids, Set<VisitHint> hints) { // Prepend the ids with the portlet namespace unless they already start with the namespace, or // if the id starts with the SeparatorChar if (ids != null) { UIViewRoot viewRoot = facesContext.getViewRoot(); String separator = String.valueOf(UINamingContainer.getSeparatorChar(facesContext)); String containerClientIdAndSeparator = viewRoot.getContainerClientId(facesContext) + separator; List<String> newIds = new ArrayList<String>(); for (String id : ids) { if (!id.startsWith(separator) && !id.startsWith(containerClientIdAndSeparator)) { id = containerClientIdAndSeparator + id; } newIds.add(id); } ids = newIds; } return wrappedVisitContextFactory.getVisitContext(facesContext, ids, hints); } }
@Override public VisitContext getVisitContext(FacesContext facesContext, Collection<String> ids, Set<VisitHint> hints) { // Prepend the ids with the portlet namespace unless they already start with the namespace, or // if the id starts with the SeparatorChar if (ids != null) { UIViewRoot viewRoot = facesContext.getViewRoot(); String separator = String.valueOf(UINamingContainer.getSeparatorChar(facesContext)); String containerClientIdAndSeparator = viewRoot.getContainerClientId(facesContext) + separator; List<String> newIds = new ArrayList<String>(); for (String id : ids) { if (!id.startsWith(separator) && !id.startsWith(containerClientIdAndSeparator)) { id = containerClientIdAndSeparator + id; } newIds.add(id); } ids = newIds; } return wrappedVisitContextFactory.getVisitContext(facesContext, ids, hints); } }
private void processComponents(UIComponent component, PhaseId phaseId, Collection<String> phaseClientIds, FacesContext context) throws IOException { // We use the tree visitor mechanism to locate the components to // process. Create our (partial) VisitContext and the // VisitCallback that will be invoked for each component that // is visited. 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); VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY); VisitContext visitContext = visitContextFactory.getVisitContext(context, phaseClientIds, hints); PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId); component.visitTree(visitContext, visitCallback); PartialVisitContext partialVisitContext = unwrapPartialVisitContext(visitContext); if (partialVisitContext != null) { if (LOGGER.isLoggable(Level.FINER) && !partialVisitContext.getUnvisitedClientIds().isEmpty()) { Collection<String> unvisitedClientIds = partialVisitContext.getUnvisitedClientIds(); StringBuilder builder = new StringBuilder(); for (String cur : unvisitedClientIds) { builder.append(cur).append(" "); } LOGGER.log(Level.FINER, "jsf.context.partial_visit_context_unvisited_children", new Object[]{builder.toString()}); } } }
private void processComponents(UIComponent component, PhaseId phaseId, Collection<String> phaseClientIds, FacesContext context) throws IOException { // We use the tree visitor mechanism to locate the components to // process. Create our (partial) VisitContext and the // VisitCallback that will be invoked for each component that // is visited. 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); VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY); VisitContext visitContext = visitContextFactory.getVisitContext(context, phaseClientIds, hints); PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId); component.visitTree(visitContext, visitCallback); PartialVisitContext partialVisitContext = unwrapPartialVisitContext(visitContext); if (partialVisitContext != null) { if (LOGGER.isLoggable(Level.FINER) && !partialVisitContext.getUnvisitedClientIds().isEmpty()) { Collection<String> unvisitedClientIds = partialVisitContext.getUnvisitedClientIds(); String message; StringBuilder builder = new StringBuilder(); for (String cur : unvisitedClientIds) { builder.append(cur).append(" "); } LOGGER.log(Level.FINER, "jsf.context.partial_visit_context_unvisited_children", new Object[]{builder.toString()}); } } }
private void processComponents(UIComponent component, PhaseId phaseId, Collection<String> phaseClientIds, FacesContext context) throws IOException { // We use the tree visitor mechanism to locate the components to // process. Create our (partial) VisitContext and the // VisitCallback that will be invoked for each component that // is visited. 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); VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY); VisitContext visitContext = visitContextFactory.getVisitContext(context, phaseClientIds, hints); PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId); component.visitTree(visitContext, visitCallback); PartialVisitContext partialVisitContext = unwrapPartialVisitContext(visitContext); if (partialVisitContext != null) { if (LOGGER.isLoggable(Level.FINER) && !partialVisitContext.getUnvisitedClientIds().isEmpty()) { Collection<String> unvisitedClientIds = partialVisitContext.getUnvisitedClientIds(); StringBuilder builder = new StringBuilder(); for (String cur : unvisitedClientIds) { builder.append(cur).append(" "); } LOGGER.log(Level.FINER, "jsf.context.partial_visit_context_unvisited_children", new Object[]{builder.toString()}); } } }
private void processComponents(UIComponent component, PhaseId phaseId, Collection<String> phaseClientIds, FacesContext context) throws IOException { // We use the tree visitor mechanism to locate the components to // process. Create our (partial) VisitContext and the // VisitCallback that will be invoked for each component that // is visited. 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); VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY); VisitContext visitContext = visitContextFactory.getVisitContext(context, phaseClientIds, hints); PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId); component.visitTree(visitContext, visitCallback); PartialVisitContext partialVisitContext = unwrapPartialVisitContext(visitContext); if (partialVisitContext != null) { if (LOGGER.isLoggable(Level.FINER) && !partialVisitContext.getUnvisitedClientIds().isEmpty()) { Collection<String> unvisitedClientIds = partialVisitContext.getUnvisitedClientIds(); StringBuilder builder = new StringBuilder(); for (String cur : unvisitedClientIds) { builder.append(cur).append(" "); } LOGGER.log(Level.FINER, "jsf.context.partial_visit_context_unvisited_children", new Object[]{builder.toString()}); } } }
private void processPartialExecute(UIViewRoot viewRoot, PhaseId phaseId) { PartialViewContext pvc = _facesContext.getPartialViewContext(); Collection<String> executeIds = pvc.getExecuteIds(); if (executeIds == null || executeIds.isEmpty()) { return; } VisitContext visitCtx = getVisitContextFactory().getVisitContext(_facesContext, executeIds, PARTIAL_EXECUTE_HINTS); viewRoot.visitTree(visitCtx, new PhaseAwareVisitCallback(_facesContext, phaseId)); }
/** * Visits activator component in order to collect its data */ private boolean visitActivatorComponent(String componentActivatorId, VisitCallback visitCallback, Set<VisitHint> visitHints) { final FacesContext facesContext = getFacesContext(); try { Set<String> idsToVisit = Collections.singleton(componentActivatorId); setVisitMode(ExtendedVisitContextMode.EXECUTE); VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder .getFactory(javax.faces.FactoryFinder.VISIT_CONTEXT_FACTORY); VisitContext visitContext = visitContextFactory.getVisitContext(facesContext, idsToVisit, visitHints); return facesContext.getViewRoot().visitTree(visitContext, visitCallback); } finally { resetVisitMode(); } }
@Override public void processPartial(PhaseId phaseId) { // If processing a partial request during the "Apply Request Values" phase of the JSF lifecycle, then register // a callback that will save-off the values of the components that are visited in the tree-walk. if (phaseId == PhaseId.APPLY_REQUEST_VALUES) { VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory( FactoryFinder.VISIT_CONTEXT_FACTORY); Collection<String> renderIds = wrappedPartialViewContext.getExecuteIds(); EnumSet<VisitHint> visitHints = EnumSet.of(VisitHint.EXECUTE_LIFECYCLE); VisitContext visitContext = visitContextFactory.getVisitContext(facesContext, renderIds, visitHints); VisitCallback visitCallback = new VisitCallbackApplyRequestValuesImpl(valueMap, validMap); facesContext.getViewRoot().visitTree(visitContext, visitCallback); } // Otherwise, if processing a partial request during the "Render Response" phase of the JSF lifecycle, then // register a callback that will remove extraneous FacesMessages for components that are visited in the // tree-walk. else if (phaseId == PhaseId.RENDER_RESPONSE) { VisitContextFactory visitContextFactory = (VisitContextFactory) FactoryFinder.getFactory( FactoryFinder.VISIT_CONTEXT_FACTORY); Collection<String> renderIds = wrappedPartialViewContext.getExecuteIds(); EnumSet<VisitHint> visitHints = EnumSet.of(VisitHint.EXECUTE_LIFECYCLE); VisitContext visitContext = visitContextFactory.getVisitContext(facesContext, renderIds, visitHints); VisitCallback visitCallback = new VisitCallbackRenderResponseImpl(facesContext, valueMap, validMap); facesContext.getViewRoot().visitTree(visitContext, visitCallback); } // Ask the delegation chain to continue partial request processing. super.processPartial(phaseId); }