public static void includeCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id) { // Prepare. FacesContext context = FacesContext.getCurrentInstance(); Application application = context.getApplication(); FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); // This basically creates <ui:component> based on <composite:interface>. Resource resource = application.getResourceHandler().createResource(resourceName, libraryName); UIComponent composite = application.createComponent(context, resource); composite.setId(id); // Mandatory for the case composite is part of UIForm! Otherwise JSF can't find inputs. // This basically creates <composite:implementation>. UIComponent implementation = application.createComponent(UIPanel.COMPONENT_TYPE); implementation.setRendererType("javax.faces.Group"); composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, implementation); // Now include the composite component file in the given parent. parent.getChildren().add(composite); parent.pushComponentToEL(context, composite); // This makes #{cc} available. try { faceletContext.includeFacelet(implementation, resource.getURL()); } catch (IOException e) { throw new FacesException(e); } finally { parent.popComponentFromEL(context); } }
FaceletContext faceletContext = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); faceletContext.includeFacelet(parentComponent, xhtmlUrl);
/** * Include the Facelet file at the given (relative) path as child of the given UI component parent. This has the * same effect as using <code><ui:include></code>. The path is relative to the current view ID and absolute * to the webcontent root. * @param parent The parent component to include the Facelet file in. * @param path The (relative) path to the Facelet file. * @throws IOException Whenever given path cannot be read. * @see FaceletContext#includeFacelet(UIComponent, String) * @since 1.5 */ public static void includeFacelet(UIComponent parent, String path) throws IOException { getFaceletContext().includeFacelet(parent, path); }
public void include() throws IOException { FacesContext facesContext = FacesContext.getCurrentInstance(); FaceletContext faceletContext = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); faceletContext.includeFacelet(facesContext.getViewRoot().findComponent("foo"), "include.xhtml"); }
/** * Include the Facelet file at the given (relative) path as child of the given UI component parent. This has the * same effect as using <code><ui:include></code>. The path is relative to the current view ID and absolute * to the webcontent root. * @param parent The parent component to include the Facelet file in. * @param path The (relative) path to the Facelet file. * @throws IOException Whenever given path cannot be read. * @see FaceletContext#includeFacelet(UIComponent, String) * @since 1.5 */ public static void includeFacelet(UIComponent parent, String path) throws IOException { getFaceletContext().includeFacelet(parent, path); }
FacesContext facesContext = FacesContext.getCurrentInstance(); FaceletContext faceletContext = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); faceletContext.includeFacelet(this, "include.xhtml"); // this is your current UIComponent.
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { String path = this.src.getValue(ctx); if (path == null || path.length() == 0) { return; } VariableMapper orig = ctx.getVariableMapper(); ctx.setVariableMapper(new VariableMapperWrapper(orig)); try { this.nextHandler.apply(ctx, null); WebConfiguration webConfig = WebConfiguration.getInstance(); if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) { throw new TagAttributeException(this.tag, this.src, "Invalid src, contract resources cannot be accessed this way : " + path); } ctx.includeFacelet(parent, path); } catch (IOException e) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, e.toString(), e); } throw new TagAttributeException(this.tag, this.src, "Invalid path : " + path); } finally { ctx.setVariableMapper(orig); } } }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException { String path = this.src.getValue(ctx); if (path == null || path.length() == 0) { return; } VariableMapper orig = ctx.getVariableMapper(); ctx.setVariableMapper(new VariableMapperWrapper(orig)); try { this.nextHandler.apply(ctx, null); WebConfiguration webConfig = WebConfiguration.getInstance(); if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) { throw new TagAttributeException(this.tag, this.src, "Invalid src, contract resources cannot be accessed this way : " + path); } ctx.includeFacelet(parent, path); } catch (IOException e) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, e.toString(), e); } throw new TagAttributeException(this.tag, this.src, "Invalid path : " + path); } finally { ctx.setVariableMapper(orig); } } }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException { String path = this.src.getValue(ctx); if (path == null || path.length() == 0) { return; } VariableMapper orig = ctx.getVariableMapper(); ctx.setVariableMapper(new VariableMapperWrapper(orig)); try { this.nextHandler.apply(ctx, null); WebConfiguration webConfig = WebConfiguration.getInstance(); if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) { throw new TagAttributeException(this.tag, this.src, "Invalid src, contract resources cannot be accessed this way : " + path); } ctx.includeFacelet(parent, path); } catch (IOException e) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, e.toString(), e); } throw new TagAttributeException(this.tag, this.src, "Invalid path : " + path); } finally { ctx.setVariableMapper(orig); } } }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException { String path = this.src.getValue(ctx); if (path == null || path.length() == 0) { return; } VariableMapper orig = ctx.getVariableMapper(); ctx.setVariableMapper(new VariableMapperWrapper(orig)); try { this.nextHandler.apply(ctx, null); WebConfiguration webConfig = WebConfiguration.getInstance(); if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) { throw new TagAttributeException(this.tag, this.src, "Invalid src, contract resources cannot be accessed this way : " + path); } ctx.includeFacelet(parent, path); } catch (IOException e) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, e.toString(), e); } throw new TagAttributeException(this.tag, this.src, "Invalid path : " + path); } finally { ctx.setVariableMapper(orig); } } }
ctx.includeFacelet(facetComponent, ccResource.getURL()); } finally { ctx.setVariableMapper(orig);
ctx.includeFacelet(facetComponent, ccResource.getURL()); } finally { ctx.setVariableMapper(orig);
ctx.includeFacelet(facetComponent, ccResource.getURL()); } finally { ctx.setVariableMapper(orig);
/** * {@inheritDoc} */ @Override public void apply(FaceletContext context, UIComponent parent) throws IOException { // acquire all objects from context to build pager PaginationHelper helper = this.helper == null ? AbstractPaginationTag.defaultPaginationHelper : (PaginationHelper) this.helper.getObject(context, PaginationHelper.class); LinksProvider provider = this.buildLinksProvider(context); // build pager links List<PaginationLink> links = helper.buildPagination( this.url.getValue(context), provider ); context.setAttribute(this.var == null ? "pageLinks" : this.var.getValue(context), links); context.includeFacelet(parent, this.view.getValue(context)); } }
public void apply(FaceletContext ctx, final UIComponent parent, String templatePath) throws IOException { AbstractFaceletContext faceletContextImpl = (AbstractFaceletContext) ctx; VariableMapper originalVariableMapper = ctx.getVariableMapper(); if (this.paramHandlers != null) { ctx.setVariableMapper(new VariableMapperWrapper(originalVariableMapper)); for (ParamHandler paramHandler : this.paramHandlers) { paramHandler.apply(ctx, parent); } } TemplateClient client = new TemplateClient() { public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException { return applyTemplate(ctx, parent, name); } }; faceletContextImpl.pushClient(client); try { ctx.includeFacelet(parent, templatePath); } finally { faceletContextImpl.popClient(client); faceletContextImpl.setVariableMapper(originalVariableMapper); } }
public void apply(FaceletContext ctx, final UIComponent parent, String templatePath) throws IOException { FaceletContextImplBase faceletContextImpl = (FaceletContextImplBase) ctx; VariableMapper originalVariableMapper = ctx.getVariableMapper(); if (this.paramHandlers != null) { ctx.setVariableMapper(new VariableMapperWrapper(originalVariableMapper)); for (ParamHandler paramHandler : this.paramHandlers) { paramHandler.apply(ctx, parent); } } TemplateClient client = new TemplateClient() { public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException { return applyTemplate(ctx, parent, name); } }; faceletContextImpl.pushClient(client); try { ctx.includeFacelet(parent, templatePath); } finally { faceletContextImpl.popClient(client); faceletContextImpl.setVariableMapper(originalVariableMapper); } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { VariableMapper orig = ctx.getVariableMapper(); if (_params != null) { VariableMapper vm = new VariableMapperWrapper(orig); ctx.setVariableMapper(vm); for (int i = 0; i < _params.length; i++) { _params[i].apply(ctx, parent); } } AbstractFaceletContext actx = (AbstractFaceletContext) ctx; actx.pushClient(this); try { ctx.includeFacelet(parent, _template.getValue(ctx)); } finally { ctx.setVariableMapper(orig); actx.popClient(this); } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { VariableMapper orig = ctx.getVariableMapper(); if (_params != null) { VariableMapper vm = new VariableMapperWrapper(orig); ctx.setVariableMapper(vm); for (int i = 0; i < _params.length; i++) { _params[i].apply(ctx, parent); } } AbstractFaceletContext actx = (AbstractFaceletContext) ctx; actx.pushClient(this); try { ctx.includeFacelet(parent, _template.getValue(ctx)); } finally { ctx.setVariableMapper(orig); actx.popClient(this); } }
ctx.includeFacelet(parent, _template.getValue(ctx));
try ctx.includeFacelet(parent, _template.getValue(ctx));