public static UIComponent addTransient( FacesContext context, ServletRequest req, UIComponent parent, String prevId, Class childClass) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); if (parent == null) { UIComponentClassicTagBase parentTag = (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent"); parent = parentTag.getComponentInstance(); BodyContent body = parentTag.getBodyContent(); if (body != null) addVerbatim(parent, body); } UIComponent child = null; ; if (child == null) child = (UIComponent) childClass.newInstance(); child.setTransient(true); addChild(parent, prevId, child); return child; }
public static UIComponent findPersistent( FacesContext context, ServletRequest req, UIComponent parent, String id) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); BodyContent body = null; if (parent == null) { UIComponentClassicTagBase parentTag = (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent"); parent = parentTag.getComponentInstance(); body = parentTag.getBodyContent(); } if (parent != null) { List<UIComponent> children = parent.getChildren(); int size = children.size(); String prevId = null; for (int i = 0; i < size; i++) { UIComponent child = children.get(i); if (id.equals(child.getId())) { if (body != null) addVerbatim(parent, prevId, body); return child; } if (child.getId() != null) prevId = child.getId(); } } return null; }
protected void setProperties(UIComponent component) { if (_binding != null) component.setValueExpression("binding", _binding); if (_rendered != null) component.setValueExpression("rendered", _rendered); String type = getRendererType(); if (type != null) component.setRendererType(type); }
public static UIComponent addFacet( FacesContext context, ServletRequest req, UIComponent parent, String facetName, ValueExpression binding, Class childClass) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); if (parent == null) { UIComponentClassicTagBase parentTag = (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent"); parent = parentTag.getComponentInstance(); } UIComponent child = null; if (binding != null) child = (UIComponent) binding.getValue(context.getELContext()); if (child == null) child = (UIComponent) childClass.newInstance(); if (parent != null) parent.getFacets().put(facetName, child); if (binding != null) binding.setValue(context.getELContext(), child); return child; }
public static UIComponent addPersistent( FacesContext context, ServletRequest req, UIComponent parent, ValueExpression binding, Class childClass) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); if (parent == null) { UIComponentClassicTagBase parentTag = (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent"); parent = parentTag.getComponentInstance(); BodyContent body = parentTag.getBodyContent(); addVerbatim(parent, body); } UIComponent child = null; if (binding != null) child = (UIComponent) binding.getValue(context.getELContext()); if (child == null) { child = (UIComponent) childClass.newInstance(); // jsf/3251 if (binding != null) binding.setValue(context.getELContext(), child); } if (parent != null) parent.getChildren().add(child); return child; }
@Override protected UIComponent createComponent(FacesContext context, String newId) throws JspException { Application app = context.getApplication(); UIComponent component; if (_binding != null) { component = app.createComponent(_binding, context, getComponentType()); component.setValueExpression("binding", _binding); } else component = app.createComponent(getComponentType()); component.setId(getId()); setProperties(component); return component; }
private static void addChild(UIComponent parent, String prevId, UIComponent child) { if (parent != null) { List<UIComponent> children = parent.getChildren(); int size = children.size(); boolean hasPrev = prevId == null; int i = 0; for (; i < size; i++) { UIComponent oldChild = children.get(i); if (hasPrev && oldChild.getId() != null) { children.add(i, child); return; } else if (prevId != null && prevId.equals(oldChild.getId())) hasPrev = true; } parent.getChildren().add(child); } }
public static UIComponent addVerbatim(UIComponent parent, String text) throws Exception { HtmlOutputText verbatim = new HtmlOutputText(); verbatim.setTransient(true); verbatim.setValue(text); verbatim.setEscape(false); parent.getChildren().add(verbatim); return verbatim; }
public static UIComponent findFacet( FacesContext context, ServletRequest req, UIComponent parent, String facetName) throws Exception { if (context == null) FacesContext.getCurrentInstance(); if (parent == null) { UIComponentClassicTagBase parentTag = (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent"); parent = parentTag.getComponentInstance(); } if (parent != null) return parent.getFacet(facetName); else return null; }