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; }
/** * Set "transient" flag to false for component and all its children ( recursive ). * * @param component */ private void markNoTransient(UIComponent component) { for (Iterator<UIComponent> iter = component.getFacetsAndChildren(); iter.hasNext(); ) { UIComponent element = iter.next(); markNoTransient(element); element.setTransient(false); } }
private static UIComponent createThemeResource( FacesContext fc, String library, String resourceName) { UIComponent resource = fc.getApplication().createComponent("javax.faces.Output"); resource.setRendererType("javax.faces.resource.Stylesheet"); resource.setTransient(true); Map<String, Object> attrs = resource.getAttributes(); attrs.put("name", resourceName); attrs.put("library", library); attrs.put("target", "head"); return resource; }
@Override public void decode(FacesContext context, UIComponent component) { rendererParamsNotNull(context, component); if (!shouldDecode(component)) { return; } String clientId = decodeBehaviors(context, component); if (clientId == null) { clientId = component.getClientId(context); } assert (clientId != null); ExternalContext externalContext = context.getExternalContext(); Map<String, String> requestMap = externalContext.getRequestParameterMap(); if (requestMap.containsKey(clientId)) { setSubmittedValue(component, requestMap.get(clientId)); } HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); try { Collection<Part> parts = request.getParts(); List<Part> multiple = new ArrayList<>(); for (Part cur : parts) { if (clientId.equals(cur.getName())) { component.setTransient(true); multiple.add(cur); } } this.setSubmittedValue(component, multiple); } catch (IOException | ServletException ioe) { throw new FacesException(ioe); } }