【问题标题】:Use an h:commandButton to toggle rich:dataScroller使用 h:commandButton 切换 rich:dataScroller
【发布时间】:2012-11-16 19:48:56
【问题描述】:

有没有人使用commandButton 来打开和关闭rich:dataScroller?我是否需要制作一个 bean 来跟踪 rich:dataScroller 是否处于活动状态并执行 commandButton 的操作来切换 bean?

【问题讨论】:

    标签: xhtml richfaces


    【解决方案1】:

    开/关是什么意思?这是否意味着显示/隐藏?如果是这样,你可以做这样的事情。 假设您有以下表格,表格下方有一个datascroller 和一个commandButton

    <h:form>
         <rich:dataTable var="_usr" value="#{myBean.users}" rows="5">
            <rich:column>
              #{_usr.userName}
            </rich:column>
            <f:facet name="footer">
              <rich:datascroller id="myScroller" />
            </f:facet>
         </rich:dataTable>
         <a4j:commandButton value="Show/Hide" onclick="toggleScroller(#{rich:element('myScroller')});"/>
    </h:form>
    

    显示/隐藏datascroller的javascript函数如下。

    <script>
      function toggleScroller(scroller) {
          if(scroller.style.display == 'none') {
              scroller.style.display = ''
            } else {
                scroller.style.display = 'none'
            }
        }
    </script>
    

    或者您可以使用&lt;rich:datascroller&gt;rendered 属性根据bean 属性来呈现它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-13
      • 2014-08-20
      • 1970-01-01
      • 2011-02-24
      • 2014-02-27
      • 2014-02-03
      • 2015-05-18
      • 1970-01-01
      相关资源
      最近更新 更多