1

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233

1 Answers1

4

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555