在此示例中,f:attribute的作用是什么? [英] What is f:attribute used for in this example?

查看:162
本文介绍了在此示例中,f:attribute的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解JSF代码段的功能.像这样

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>

field属性引用具有getValue() / setValue()访问器(用于字符串)的bean成员. value属性是一个来自其他地方的字符串.

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.

据我了解,output的值最初设置为(静态)value属性:value="#{cc.attrs.value}",然后<f:attribute>标记将 something 设置为从字段" bean中检索到的动态"值.

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?

推荐答案

正如您所猜测的,这确实与以下内容完全相同:

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.

这篇关于在此示例中,f:attribute的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆