【问题标题】:Enum values in Composite Component attribute复合组件属性中的枚举值
【发布时间】:2011-12-15 16:43:18
【问题描述】:

我的问题很简单:我想创建一个具有字符串属性 Type 的复合组件。

<cc:attribute name="type" /> 该属性将有 3 个可接受的值,[TYPE1, TYPE2, TYPE3]

是否可以说我的组件只接受这些值?

【问题讨论】:

    标签: attributes jsf-2 composite-component


    【解决方案1】:

    很遗憾,您不能对 cc 接口中的复合组件属性值设置编译/构建时间限制。但是,您可以通过检查 cc 实现中的值来设置运行时限制。

    <ui:param name="type" value="#{cc.attrs.type}" />
    <ui:fragment rendered="#{type == 'TYPE1' or type == 'TYPE2' or type == 'TYPE3'}">
        <p>The type is TYPE1, TYPE2 or TYPE3.</p>
        <p>Write your component's body here.</p>
    </ui:fragment>
    

    这将是你最好的选择。

    【讨论】:

    • 谢谢,这对我来说不是什么大问题......但我认为它会很干净。没关系!
    猜你喜欢
    • 2017-04-23
    • 1970-01-01
    • 2013-05-01
    • 2010-12-20
    • 2013-05-29
    • 2011-02-16
    相关资源
    最近更新 更多