composite component - Why is my JSF FacletContext==null? -
my faceletcontext
try
faceletcontext faceletcontext = (faceletcontext) context.getattributes().get(faceletcontext.facelet_context_key);
is null
. going wrong here?
actually try add composite component dynamically bean.
update:
to more clear. have following bean:
@named @sessionscoped public class groupcomponenttreebuilder implements serializable { public uicomponent getgrouptree() { uicomponent parent1 = uicomponent.getcurrentcomponent(facescontext.getcurrentinstance()); return includecompositecomponent(parent1, "group", "elementgroup.xhtml", "mynewsuperid"); } public static uicomponent includecompositecomponent(uicomponent parent, string libraryname, string resourcename, string id) { facescontext context = faces.getcontext(); application application = context.getapplication(); faceletcontext faceletcontext = faces.getfaceletcontext(); resource resource = application.getresourcehandler().createresource(resourcename, libraryname); uicomponent composite = application.createcomponent(context, resource); composite.setid(id); uicomponent implementation = application.createcomponent(uipanel.component_type); implementation.setrenderertype("javax.faces.group"); composite.getfacets().put(uicomponent.composite_facet_name, implementation); parent.getchildren().add(composite); parent.pushcomponenttoel(context, composite); // makes #{cc} // available. try { faceletcontext.includefacelet(implementation, resource.geturl()); } catch (ioexception e) { throw new facesexception(e); } { parent.popcomponentfromel(context); } return composite; } }
and want bind loaded bean panelgroup :
<ui:fragment> <h:panelgroup binding="#{groupcomponenttreebuilder.grouptree}" /> </ui:fragment>
the problem facletcontext null, can not call includerfacelet ().
any suggestions?
the problem that
faceletcontext.facelet_context_key
returned wrong string key "com.sun.faces.facelets.facelet_context"
but needed
javax.faces.facelet_context
thanx mat :-)
Comments
Post a Comment