jsf - How is an instance of composite component created and how can I get it -


i'm using mojarra 2.1. reading this answer when use custom tags , composite components, came across question internals of components.

so, important difference between custom tags , composite components every composite component has single uicomponent instance, representing in component tree after view build time's finshed. custom tag, in turn doesn't have single uicomponent instance representing in tree.

so, class, representing composite component in tree? how created? anonymous class? let's consider example wiki-page:

    <ui:component     xmlns="http://www.w3.org/1999/xhtml"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:cc="http://java.sun.com/jsf/composite" >     <cc:interface>         <!-- define component attributes here -->     </cc:interface>     <cc:implementation>         <!-- define component body here -->     </cc:implementation> </ui:component> 

how can instance of uicomponent, representing composite component?

digging source code of uicomponent found following method:

public static boolean iscompositecomponent(uicomponent component) {          if (component == null) {             throw new nullpointerexception();         }         boolean result = false;         if (null != component.iscompositecomponent) {             result = component.iscompositecomponent.booleanvalue();         } else {             result = component.iscompositecomponent =                     (component.getattributes().containskey(                                resource.component_resource_key));         }         return result;      } 

i suspect it's implementation details how composite-component class created. in fact, i'd find mojarra implemenattion generates composite component class instance.

upd: defintion of composite compoent's replaced 1 doesn't explicitly defines componenttype attribute.

it's uipanel instance can via uicomponent#findcomponent() usual way, passing composite component client id. in case of mojarra, can find code responsible creating in com.sun.faces.facelets.tag.jsf.compositecomponenttaghandler has in mojarra 2.2.11 below logic:

360        if (componenthandler.isnew(c)) { 361            facetcomponent = (uipanel) 362            facescontext.getapplication().createcomponent("javax.faces.panel"); 363            facetcomponent.setrenderertype("javax.faces.group"); 364            c.getfacets().put(uicomponent.composite_facet_name, facetcomponent); 365        }                                                                                  366        else { 367            facetcomponent = (uipanel)  368                    c.getfacets().get(uicomponent.composite_facet_name); 369        } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -