/** * Finds the proper {@link AjaxExceptionHandler} for the given {@link Throwable}. * * @param context The {@link FacesContext}. * @param rootCause The occurred {@link Throwable}. * @return The {@link AjaxExceptionHandler} or <code>null</code>. */ protected AjaxExceptionHandler findHandlerComponent(FacesContext context, Throwable rootCause) { AjaxExceptionHandlerVisitCallback visitCallback = new AjaxExceptionHandlerVisitCallback(rootCause); context.getViewRoot().visitTree(VisitContext.createVisitContext(context), visitCallback); Map<String, AjaxExceptionHandler> handlers = visitCallback.getHandlers(); // get handler by exception type AjaxExceptionHandler handler = handlers.get(rootCause.getClass().getName()); // lookup by inheritance hierarchy if (handler == null) { Class throwableClass = rootCause.getClass(); while (handler == null && throwableClass.getSuperclass() != Object.class) { throwableClass = throwableClass.getSuperclass(); handler = handlers.get(throwableClass.getName()); } } // get default handler if (handler == null) { handler = handlers.get(null); } return handler; }
@Override public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, int options) { try { Matcher matcher = PATTERN.matcher(expression); if (matcher.matches()) { WidgetVarVisitCallback visitCallback = new WidgetVarVisitCallback(matcher.group(1)); context.getViewRoot().visitTree( SearchExpressionUtils.createVisitContext(context, options), visitCallback); return visitCallback.getComponent(); } else { throw new FacesException("Expression does not match following pattern @widgetVar(var). Expression: \"" + expression + "\""); } } catch (Exception e) { throw new FacesException("Expression does not match following pattern @widgetVar(var). Expression: \"" + expression + "\"", e); } }
context.getViewRoot().visitTree(visitContext, ResetInputVisitCallback.INSTANCE);
@Override public void export(FacesContext context, List<String> clientIds, String filename, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, ExporterOptions options, MethodExpression onTableRender) throws IOException { Workbook wb = createWorkBook(); if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[]{wb}); } VisitContext visitContext = VisitContext.createVisitContext(context, clientIds, null); VisitCallback visitCallback = new ExcelExportVisitCallback(this, wb, pageOnly, selectionOnly); context.getViewRoot().visitTree(visitContext, visitCallback); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[]{wb}); } writeExcelToResponse(context.getExternalContext(), wb, filename); }
@Override public void resolve(SearchKeywordContext context, UIComponent current, String keyword) { try { Matcher matcher = PATTERN.matcher(keyword); if (matcher.matches()) { WidgetVarVisitCallback visitCallback = new WidgetVarVisitCallback(matcher.group(1)); context.getSearchExpressionContext().getFacesContext().getViewRoot().visitTree( SearchExpressionUtils.createVisitContext( context.getSearchExpressionContext().getFacesContext(), SearchExpressionHint.SKIP_UNRENDERED), visitCallback); context.invokeContextCallback(visitCallback.getComponent()); } else { throw new FacesException("Expression does not match following pattern @widgetVar(var). Expression: \"" + keyword + "\""); } } catch (Exception e) { throw new FacesException("Expression does not match following pattern @widgetVar(var). Expression: \"" + keyword + "\"", e); } } }
context.getViewRoot().visitTree(visitContext, visitCallback);
/** * @since 2.2 * @param context * @param clientIds */ public void resetValues(FacesContext context, java.util.Collection<java.lang.String> clientIds) { VisitContext visitContext = (VisitContext) VisitContext.createVisitContext( context, clientIds, null); this.visitTree(visitContext, RESET_VALUES_CALLBACK); }
private DOMPartialRenderCallback renderSubtrees(UIViewRoot viewRoot, Collection<String> renderIds) { EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED); VisitContext visitContext = VisitContext.createVisitContext(facesContext, renderIds, hints); DOMPartialRenderCallback renderCallback = new DOMPartialRenderCallback(diffConfig, facesContext); viewRoot.visitTree(visitContext, renderCallback); //if subtree diffs fail, consider throwing an exception to trigger //a full page diff. This may depend on development vs production return renderCallback; }
@Override public void processPartial(PhaseId phaseId) { UIViewRoot viewRoot = _facesContext.getViewRoot(); VisitContext visitCtx = VisitContext.createVisitContext(_facesContext, null, null); viewRoot.visitTree(visitCtx, new MockVisitCallback()); }
private void customRenderSubtrees(UIViewRoot viewRoot, Collection<String> renderIds) { EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED); VisitContext visitContext = VisitContext.createVisitContext(facesContext, renderIds, hints); CustomPartialRenderCallback renderCallback = new CustomPartialRenderCallback(facesContext); viewRoot.visitTree(visitContext, renderCallback); return; }
public void run() { root.visitTree(new FullVisitContext(context), new AddNGModelAndIDCallback()); } });
public void run() { root.visitTree(new FullVisitContext(context), new TranslationCallback(ajaxRequest)); } });
/** * <p class="changed_added_2_2">Visit the clientIds and, if the component is * an instance of {@link EditableValueHolder}, * call its {@link EditableValueHolder#resetValue} method. * Use {@link #visitTree} to do the visiting.</p> * * @since 2.2 * @param context the {@link FacesContext} for the request we are processing. * @param clientIds The client ids to be visited, on which the described action will be taken. */ public void resetValues(FacesContext context, Collection<String> clientIds) { this.visitTree(VisitContext.createVisitContext(context, clientIds, null), new DoResetValues()); }
/** * <p class="changed_added_2_2">Visit the clientIds and, if the component is * an instance of {@link EditableValueHolder}, * call its {@link EditableValueHolder#resetValue} method. * Use {@link #visitTree} to do the visiting.</p> * * @since 2.2 * @param context the {@link FacesContext} for the request we are processing. * @param clientIds The client ids to be visited, on which the described action will be taken. */ public void resetValues(FacesContext context, Collection<String> clientIds) { this.visitTree(VisitContext.createVisitContext(context, clientIds, null), new DoResetValues()); }
/** * <p class="changed_added_2_2">Visit the clientIds and, if the component is * an instance of {@link EditableValueHolder}, * call its {@link EditableValueHolder#resetValue} method. * Use {@link #visitTree} to do the visiting.</p> * * @since 2.2 * @param context the {@link FacesContext} for the request we are processing. * @param clientIds The client ids to be visited, on which the described action will be taken. */ public void resetValues(FacesContext context, Collection<String> clientIds) { this.visitTree(VisitContext.createVisitContext(context, clientIds, null), new DoResetValues()); }
public void run() { root.visitTree(new FullVisitContext(context), new PuiSelectItemTagHandler()); } });
public void run() { root.visitTree(new FullVisitContext(context), new AddTypeInformationCallback()); } });
/** * <p class="changed_added_2_2">Visit the clientIds and, if the component is * an instance of {@link EditableValueHolder}, * call its {@link EditableValueHolder#resetValue} method. * Use {@link #visitTree} to do the visiting.</p> * * @since 2.2 * @param context the {@link FacesContext} for the request we are processing. * @param clientIds The client ids to be visited, on which the described action will be taken. */ public void resetValues(FacesContext context, Collection<String> clientIds) { this.visitTree(VisitContext.createVisitContext(context, clientIds, null), new DoResetValues()); }
private void processPartialExecute(UIViewRoot viewRoot, PhaseId phaseId) { PartialViewContext pvc = _facesContext.getPartialViewContext(); Collection<String> executeIds = pvc.getExecuteIds(); if (executeIds == null || executeIds.isEmpty()) { return; } Set<VisitHint> hints = new HashSet<VisitHint>(); hints.add(VisitHint.EXECUTE_LIFECYCLE); hints.add(VisitHint.SKIP_UNRENDERED); VisitContext visitCtx = VisitContext.createVisitContext(_facesContext, executeIds, hints); viewRoot.visitTree(visitCtx, new PhaseAwareVisitCallback(_facesContext, phaseId)); }
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)); }