How to create a composite of existing components in JSF? -
i'd know if it's possible compose own component (or call widget, object).
i mean, instead of (for example) using h:panelgroup
, h:outputlabel
inside it, make own h:panelmarkzzz
, composition of panelgroup , outputlabel.
is possible on jsf?
yes, it's possible create composition of existing components that.
kickoff example:
/resources/foo/group.xhtml
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:cc="http://xmlns.jcp.org/jsf/composite"> <cc:interface> <cc:attribute name="label" type="java.lang.string" required="true" /> </cc:interface> <cc:implementation> <h:panelgroup> <h:outputlabel value="#{cc.attrs.label}" /> <cc:insertchildren /> </h:panelgroup> </cc:implementation> </html>
/test.xhtml
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:foo="http://xmlns.jcp.org/jsf/composite/foo"> <h:head> <title>test</title> </h:head> <h:body> <foo:group label="label value"> <h:outputtext value="this appear after label inside panelgroup" /> </foo:group> </h:body> </html>
the /foo
folder name free taste , can reference in xml namespace http://xmlns.jcp.org/jsf/composite/xxx
. xhtml filename tag name.
that said, composite components have performance implications , should used when functional requirement not achievable using simple include or tagfile. in specific case, you'd better use tagfile instead. composite component worthy when need <cc:interface componenttype="...">
.
Comments
Post a Comment