Reputation: 4014
I have a UIComponent
that is binded to a backing bean. I'd like to add a child to the component that corresponds to the ui:include
tag, through my backing bean's init method.
for example:
<p:tab>
<ui:include src="/page.xhtml" />
</p:tab>
I want to create this in my backing bean like:
<p:tab binding="${bean.tab}" />
So basicly i'm looking for the corresponding UIComponent class for the ui:include, so i can add this as a child to my tab property.
Thanks!
UPDATE:
I'm now trying with faceletContext.includeFacelet :)
Upvotes: 0
Views: 2631
Reputation: 4014
Ok, it's working :) Get the faceletContext from facescontext:
FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
Upvotes: 0
Reputation: 306
i have read this thread 20 time and i couldn't find the solution at first so here are my additional comment for it after i found the right way:
FacesContext facesContext = FacesContext.getCurrentInstance();
FaceletFactory defaultFactory = ApplicationAssociate.getInstance(facesContext.getExternalContext()).getFaceletFactory();
Facelet facelet = defaultFactory.getFacelet(xhtmlUrl);
Then i have created a FaceletHandler to add the component.
Another solution was :
FaceletContext faceletContext = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
faceletContext.includeFacelet(parentComponent, xhtmlUrl);
Upvotes: 1