隐式对象cc和组件之间的jsf差异 [英] jsf difference between implicit objects cc and component

查看:151
本文介绍了隐式对象cc和组件之间的jsf差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个愚蠢的问题,但我使用

Maybe this is a dumb question, but I use

cc

引用复合组件,例如cc.attrs.randomAttr,但我也看到了

to refer to the composite component, for instance cc.attrs.randomAttr but I have also seen the

component

隐式对象我使用过它因为我被告知,但我真的不明白它是什么。任何人都可以解释一下吗?

implicit object and I have used it because I was told to but I don't really understand what it is for. Can anyone explain please?

推荐答案

cc 指的是顶级复合材料在评估时正在处理的组件。

cc refers to the top level composite component that is being processed at the time of evaluation.

组件只是正在处理的ui组件。

component simply is the ui component being processed.

因此,当在复合组件内部时, cc 引用父组件,而组件在单个组件上使用时,指的是该特定实例。或者对于简单案例:

So when inside a composite component, cc refers to the 'parent' component, while component when used on an individual component refers to that particular instance. Or for simple cases:

cc == 组件.getCompositeComponentParent(component),其中组件是构建复合组件的组件。

cc == component.getCompositeComponentParent(component), with component being a component of which the composite component is build.

例如考虑以下复合组件:

E.g. consider the following composite component:

<html 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"    
    xmlns:cc="http://java.sun.com/jsf/composite"
>
    <cc:interface/>

    <cc:implementation>

        <h:outputText value="Own ID: #{component.id}, parent composite ID: #{cc.id}" /> <br/>
        <h:outputText value="Own ID: #{component.id}, parent composite ID: #{cc.id}" />

    </cc:implementation>    

</html>

在Facelet上使用它将打印2个不同的自有ID,即两个outputText中的ID组件,而复合ID在两行上都是相同的。

Using this on a Facelet will print 2 different "own" IDs, namely the ones of the two outputText components, while the composite ID will be the same on both lines.

请注意,当涉及多个复合组件嵌套时,事情可能会变得有点复杂。

Note that things may become a little more complicated when multiple nestings of composite components are involved.

这篇关于隐式对象cc和组件之间的jsf差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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