/** * @see javax.faces.component.UIComponentBase#getChildren() */ public List getChildren() { return original.getChildren(); }
public void postEncodeEnd(final FacesContext context) throws IOException { final UIViewRoot viewRoot = context.getViewRoot(); if (viewRoot != null) { viewRoot.getChildren().clear(); } }
private void swapChildren(UIViewRoot source, UIViewRoot target) { target.getChildren().addAll(source.getChildren()); Iterator i = target.getChildren().iterator(); while (i.hasNext()) { UIComponent child = (UIComponent) i.next(); child.setParent(target); } }
/** * Looks for the header in the JSF tree. * * @param root The root of the JSF tree. * @return null, if the head couldn't be found. */ private UIComponent findHeader(UIViewRoot root) { for (UIComponent c : root.getChildren()) { if (c instanceof HtmlHead) return c; } for (UIComponent c : root.getChildren()) { if (c instanceof HtmlBody) return null; if (c instanceof UIOutput) if (c.getFacets() != null) return c; } return null; }
/** * Looks for the header in the JSF tree. * * @param root The root of the JSF tree. * @return null, if the head couldn't be found. */ private UIComponent findHeader(UIViewRoot root) { for (UIComponent c : root.getChildren()) { if (c instanceof HtmlHead) return c; } for (UIComponent c : root.getChildren()) { if (c instanceof HtmlBody) return null; if (c instanceof UIOutput) if (c.getFacets() != null) return c; } return null; }
/** * Invoke the registered cleanup method for the bean's instance */ public void invokeCleanupMethod() { if (instance instanceof UIViewRoot) { UIViewRoot uiViewRoot = ((UIViewRoot)instance); uiViewRoot.getChildren().clear(); uiViewRoot.getFacets().clear(); } }
public int doAfterBody() throws JspException { if (log.isTraceEnabled()) log.trace("entering ViewTag.doAfterBody"); UIComponent verbatimComp = createVerbatimComponentFromBodyContent(); if (verbatimComp != null) { FacesContext.getCurrentInstance().getViewRoot().getChildren() .add(verbatimComp); } if (log.isTraceEnabled()) log.trace("leaving ViewTag.doAfterBody"); return EVAL_PAGE; }
/** * used by GrowlMessagesRenderer and MessagesRenderer for option @inView * * @param context * @return list of ids in view */ public static List<String> findIdsInView(FacesContext context) { List<String> idList = new ArrayList<String>(); UIViewRoot root = context.getViewRoot(); for (UIComponent uic : root.getChildren()) { getChildIds(uic, idList, context); } return idList; }
@Override public int doAfterBody() throws JspException { if (log.isLoggable(Level.FINEST)) log.finest("entering ViewTag.doAfterBody"); UIComponent verbatimComp = createVerbatimComponentFromBodyContent(); if (verbatimComp != null) { FacesContext.getCurrentInstance().getViewRoot().getChildren().add(verbatimComp); } if (log.isLoggable(Level.FINEST)) log.finest("leaving ViewTag.doAfterBody"); return EVAL_PAGE; }
@Override public int doAfterBody() throws JspException { if (log.isLoggable(Level.FINEST)) log.finest("entering ViewTag.doAfterBody"); UIComponent verbatimComp = createVerbatimComponentFromBodyContent(); if (verbatimComp != null) { FacesContext.getCurrentInstance().getViewRoot().getChildren().add(verbatimComp); } if (log.isLoggable(Level.FINEST)) log.finest("leaving ViewTag.doAfterBody"); return EVAL_PAGE; }
@Override public int doAfterBody() throws JspException { if (log.isLoggable(Level.FINEST)) { log.finest("entering ViewTag.doAfterBody"); } UIComponent verbatimComp = createVerbatimComponentFromBodyContent(); if (verbatimComp != null) { FacesContext.getCurrentInstance().getViewRoot().getChildren().add(verbatimComp); } if (log.isLoggable(Level.FINEST)) { log.finest("leaving ViewTag.doAfterBody"); } return EVAL_PAGE; }
private void removeWindowContextIdHolderComponent(FacesContext facesContext) { JsfUtils.resetCaches(); UIViewRoot viewRoot = facesContext.getViewRoot(); if (viewRoot == null) { // if the viewRoot is not yet set, then we don't have anything to remove. return; } Iterator<UIComponent> uiComponents = viewRoot.getChildren().iterator(); UIComponent uiComponent; while (uiComponents.hasNext()) { uiComponent = uiComponents.next(); if (uiComponent instanceof WindowContextIdHolderComponent) { uiComponents.remove(); return; } } }
/** * Attach the holder component to the view root and set the optional model. * @param context the faces context * @param viewRoot the view root * @param model an optional model * @return the attached model */ public static SpringFacesModel attach(FacesContext context, UIViewRoot viewRoot, Map<String, ?> model) { Assert.notNull(context, "FacesContext must not be null"); Assert.notNull(viewRoot, "ViewRoot must not be null"); SpringFacesModelHolder holder = new SpringFacesModelHolder(model); viewRoot.getChildren().add(holder); return holder.getModel(); }
/** * Saves the flow execution key in a component in the view root for restoration on subsequent RESTORE_VIEW * operations. * @param facesContext the faces context exposing the view root * @param flowExecutionKey the flow execution key */ private void saveInViewRoot(FacesContext facesContext, String flowExecutionKey) { // search for key holder in the component tree FlowExecutionKeyStateHolder keyHolder = (FlowExecutionKeyStateHolder) facesContext.getViewRoot().findComponent( FlowExecutionKeyStateHolder.COMPONENT_ID); if (keyHolder == null) { keyHolder = createFlowExecutionKeyStateHolder(); // expose in the view root for preservation in the component tree facesContext.getViewRoot().getChildren().add(keyHolder); } keyHolder.setFlowExecutionKey(flowExecutionKey); }
public static UIViewRoot findRoot(FacesContext context, ServletRequest req, Object etag) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); UIViewRoot root = context.getViewRoot(); if (root == null) throw new NullPointerException(L.l("f:view can't find current in FacesContext")); Object oldETag = root.getAttributes().get("caucho.etag"); if (oldETag != null && ! oldETag.equals(etag)) { // clear view on JSP change root.getChildren().clear(); root.getFacets().clear(); } root.getAttributes().put("caucho.etag", etag); return root; }
private void processRenderAll(UIViewRoot viewRoot, PartialResponseWriter writer) throws IOException { //java.util.Iterator<UIComponent> iter = viewRoot.getFacetsAndChildren(); writer.startUpdate (PartialResponseWriter.RENDER_ALL_MARKER); //while (iter.hasNext()) //{ //UIComponent comp = iter.next(); //TODO: Do not check for a specific instance, //just render all children. //if (comp instanceof javax.faces.component.html.HtmlBody) //{ //comp.encodeAll (_facesContext); //} //} for (UIComponent comp : viewRoot.getChildren()) { comp.encodeAll (_facesContext); } writer.endUpdate(); }
private void processRenderAll(UIViewRoot viewRoot, PartialResponseWriter writer) throws IOException { //java.util.Iterator<UIComponent> iter = viewRoot.getFacetsAndChildren(); writer.startUpdate (PartialResponseWriter.RENDER_ALL_MARKER); //while (iter.hasNext()) //{ //UIComponent comp = iter.next(); //TODO: Do not check for a specific instance, //just render all children. //if (comp instanceof javax.faces.component.html.HtmlBody) //{ //comp.encodeAll (_facesContext); //} //} for (UIComponent comp : viewRoot.getChildren()) { comp.encodeAll (_facesContext); } writer.endUpdate(); }
private void processRenderAll(UIViewRoot viewRoot, PartialResponseWriter writer) throws IOException { // Before render all we need to clear rendered resources set to be sure every component resource is // rendered. Remember renderAll means the whole page is replaced, so everything inside <head> is replaced. // and there is no way to diff between the old and the new content of <head>. Map<String, Boolean> map = (Map) viewRoot.getTransientStateHelper().getTransient( ResourceHandlerImpl.RENDERED_RESOURCES_SET); if (map != null) { map.clear(); } writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER); for (int i = 0, childCount = viewRoot.getChildCount(); i < childCount; i++) { UIComponent comp = viewRoot.getChildren().get(i); comp.encodeAll(_facesContext); } writer.endUpdate(); }
public void testProcessActionWithUIRepeat() { UIRepeat uiRepeat = new UIRepeat(); uiRepeat.setValue(this.dataModel); UICommand commandButton = new UICommand(); uiRepeat.getChildren().add(commandButton); this.viewToTest.getChildren().add(uiRepeat); Method indexMutator = ReflectionUtils.findMethod(UIRepeat.class, "setIndex", FacesContext.class, int.class); indexMutator.setAccessible(true); ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new MockFacesContext(), 1); ActionEvent event = new ActionEvent(commandButton); this.selectionTrackingListener.processAction(event); assertTrue(this.dataModel.isCurrentRowSelected()); assertSame(this.dataModel.getSelectedRow(), this.dataModel.getRowData()); assertTrue(this.delegateListener.processedEvent); ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new MockFacesContext(), 2); assertFalse(this.dataModel.isCurrentRowSelected()); assertTrue(this.dataModel.getSelectedRow() != this.dataModel.getRowData()); }
public void testProcessActionWithUIData() { UIData dataTable = new UIData(); dataTable.setValue(this.dataModel); UIColumn column = new UIColumn(); UICommand commandButton = new UICommand(); column.getChildren().add(commandButton); dataTable.getChildren().add(column); this.viewToTest.getChildren().add(dataTable); dataTable.setRowIndex(1); ActionEvent event = new ActionEvent(commandButton); this.selectionTrackingListener.processAction(event); assertTrue(this.dataModel.isCurrentRowSelected()); assertSame(this.dataModel.getSelectedRow(), this.dataModel.getRowData()); assertTrue(this.delegateListener.processedEvent); this.dataModel.setRowIndex(2); assertFalse(this.dataModel.isCurrentRowSelected()); assertTrue(this.dataModel.getSelectedRow() != this.dataModel.getRowData()); }