【问题标题】:Use either action or actionListener based on a condition in a PF datatable composite component根据 PF 数据表复合组件中的条件使用 action 或 actionListener
【发布时间】:2014-11-23 15:13:29
【问题描述】:

我正在尝试创建一个数据表复合组件,该组件需要由两组开发人员使用,一组使用Spring web flow,他们需要一个action 属性用于复合组件数据表中的命令链接和其他人需要actionListener 属性。

我想对这两种情况使用相同的 xhtml。这可行吗?

  <composite:attribute name="isWebFlow" />   

上面的属性能帮我配置吗?问题是我在数据表复合组件中有许多命令链接,因此我无法根据以下条件重复/渲染它们:

<c:if test="#{cc.attrs.isWebFlow eq 'true'}">  
     <p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}"/>
</c:if>    

<c:if test="#{cc.attrs.isWebFlow eq 'false'}">  
    <p:commandLink styleClass="filter #{cc.attrs.styleClass}" actionListener="#{cc.attrs.actionListener}"/>
</c:if>  

还有其他方法可以做到这一点并重新使用 xhtml 吗?提前致谢。

【问题讨论】:

    标签: jsf primefaces datatable composite-component


    【解决方案1】:

    尝试使用渲染属性:

    <p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}" rendered="#{isWebFlow}"/> <p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}" rendered="#{!isWebFlow}"/>
    

    【讨论】:

    • 我在 xhtml 中有很多这样的命令链接,我不能像问题中已经提到的那样重复这样的代码。
    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 2020-05-13
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多