I used to have a bunch of <ui:composition>
templates and include them by
<ui:include src="${bean.type}.xhtml">
<ui:param name="model" value="#{model}"/>
</ui:include>
${bean.type}
gave the relative path to the template with the name. For example,
/a/b/c/table
/a/c/d/timeline
Now I am refactoring them to <ui:component>
s
<cc:interface componentType="table">
<cc:attribute name="model" type="my.company.Model" required="true"/>
</cc:interface>
<cc:implementation>
<!-- -->
</cc:implementation>
or considering the option of defining the markup in the encodeXXX
methods
class Widget extends UIComponentBase {}
class Table extends Widget {}
class TimeLine extends Widget {}
meaning I will end up with components
mycompany:table
mycompany:timeline
At the moment, I can't declare them having only their name coming from the bean's property
<mycompany:${bean.type} model="#{model}" />
<!-- this obviously doesn't work, but nicely illustrates the idea -->
I don't want to to the rendered
magic rendering a certain tag only if the property matches the type. I am looking for a scalable solution because the hierarchy of the custom components is huge and I don't want to just list all of them in the template
<mycompany:table rendered="${bean.type == 'table'}" />
<mycompany:timeline rendered="${bean.type == 'timeline'}" />
<!-- and a lot more -->
I was looking for some kind of a tag/component resolver that I would give an "abstract" tag to
<mycompany:widget model="#{model}">
and it would resolve it to the proper widget subclass taking into account #{bean.type}
, similarly to what Application#createComponent(context, name)
does.
Thanks.
Related: