What is f:attribute used for in this example?

孤者浪人 提交于 2019-12-11 06:36:13

问题


I'm trying to understand what a JSF snippet does. It goes something like this

<composite:interface>
    <composite:attribute name="field" />
    <composite:attribute name="value" default=""/>
    [...]
</composite:interface>
<composite:implementation>
     <ui:fragment rendered="some_logic_here">
         <h:outputText value="#{cc.attrs.value}">
             <f:attribute name="value" value="#{cc.attrs.field.value}"/>
         </h:outputText>
     </ui:fragment>
</composite:implementation>

The field attribute refers to a bean member that has getValue() / setValue() accessors (for a string). The value attribute is a string that comes from elsewhere.

From what I understand, the output's value is initially set to the (static) value attribute: value="#{cc.attrs.value}", then the <f:attribute> tag sets something to the "dynamic" value retrieved from the "field" bean.

How does this work out? Does the "dynamic" value override the static one? Always?


回答1:


As you guessed, this does indeed exactly the same as:

<h:outputText value="#{cc.attrs.field.value}" />

In other words, the original developer didn't thought out it very well, or was fiddling until it started to work like magic, or perhaps had a short on coffee, or smoked something bad while developing.



来源:https://stackoverflow.com/questions/18231951/what-is-fattribute-used-for-in-this-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!