是否可以传递某种参数化片段/模板以在复合组件中重复使用?
<my:list value="#{someBean.ratios}" var="ratio">
<???>
<h:outputText value="#{ratio}">
<f:convertNumber type="percent" maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</???>
</my:list>
使用以下my:list
组件:
<ui:component>
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="var" />
</cc:interface>
<cc:implementation>
<ul>
<ui:repeat value="#{cc.attrs.value}" var="item">
<li>
<???insert body/fragment/template???>
<ui:param name="#{cc.attrs.var}" value="#{item}" />
</???insert body/fragment/template???>
</li>
</ui:repeat>
</ul>
</cc:implementation>
</ui:component>
更新我也尝试了类似的东西,但它不起作用:
<my:list value="#{someBean.ratios}">
<f:convertNumber type="percent" maxFractionDigits="2" minFractionDigits="2" for="output" />
</my:list>
将组件定义为:
<ui:component>
<cc:interface>
<cc:attribute name="value" />
</cc:interface>
<cc:implementation>
<ul>
<ui:repeat value="#{cc.attrs.value}" var="item">
<li>
<h:outputText value="#{item}" id="output" />
</li>
</ui:repeat>
</ul>
</cc:implementation>
</ui:component>