t:dataScroller在刷新时无法正常工作 [英] t:dataScroller not working correctly on refresh

查看:105
本文介绍了t:dataScroller在刷新时无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用t:dataScroller从at:dataTable滚动一些数据,除了以下几点外,它工作正常:每次触发一次导致刷新屏幕的动作时,t:dataScroller的索引设置为1

I'm using t:dataScroller to scroll some data from a t:dataTable and it is working fine except for one thing: every time an action that causes the screen to be refreshed is triggered the t:dataScroller's index is set to 1.

更清楚一点:当我进入第二页(索引== 2)并且触发屏幕刷新操作时,刷新后,dataTable的数据仍来自索引2,但dataScroller显示该页面显示的是第一个.

To be more clear: when i'm in the second page (index == 2) and a screen refreshing action triggers, after the refresh, the data of the dataTable is still from index 2 but the dataScroller shows that the page being displayed is the first one.

我以这种方式使用dataScroller:

I'm using the dataScroller this way:

<t:dataScroller for="myDataTable" id="myDataScroller" paginator="true"
    paginatorMaxPages="#{myBean.paginatorMxPgs}" 
    pageCountVar="pgCount" pageIndexVar="#{myBean.curPg}"
    actionListener="#{myBean.pgListener}">

<f:facet name="prv">
    <h:panelGroup rendered="#{myBean.curPg > 1}" />
</f:facet>
<f:facet name="nxt">
    <h:panelGroup rendered="#{myBean.curPg != pgCount}"/>
</f:facet>
</t:dataScroller>

我正在使用 tomahawk20-1.1.11.jar myfaces-api-2.0.4.jar

推荐答案

要将滚动条设置为首页,请在提交按钮上设置actionlistener.

For setting scroller to firstpage set actionlistener on submit button.

<t:commandButton actionListener="#{IFussBean.resetDataScroller}" 
                   action="#{IFussBean.searchLocation}" 
                   image="images/submit-button.png">    
  </t:commandButton>

绑定:

如果它是数据表

<t:dataTable id="data"
             headerClass=""
             footerClass=""
             rowClasses="text_holder"
             columnClasses="search_img,search_txt"
             var="item"
             value="#{IFussBean.searchVideoList}"
             preserveDataModel="false"
             rows= "6"
             binding="#{IFussBean.iFussData}"
 >

在您的Bean中声明HtmlDataTable,如下定义其setter getter:

Declare HtmlDataTable in your Bean,define its setter getter as below:

private HtmlDataTable iFussData;

字母和字母设置器

 public HtmlDataTable getiFussData() {
        return iFussData;
    }
    public void setiFussData(HtmlDataTable iFussData) {
        this.iFussData = iFussData;
    }

现在在Bean中定义ActionListener方法:

Now define ActionListener Method in Bean:

public void resetDataScroller(ActionEvent e) {
       if(iFussData!= null) {
           iFussData.setFirst(0);
       }
}

进行新搜索时,您的页面将设置为首页.

Your page will set to first page when you'll do new search.

/ * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * / 如果您使用的是<rich:dataGrid>并且滚动条是<t:dataScroller>,则

/**********************************************************************************************************************************/ if you are using <rich:dataGrid> and your scroller is <t:dataScroller> then

 <rich:dataGrid 
            id="data"
            var="item" 
            columns="3" 
            elements="6" 
            width="600px"
            value="#{IFussBean.searchVideoList}"
            binding="#{IFussBean.iFussDataGrid}"
    >

在Bean中声明HtmlDataGrid:

Declare HtmlDataGrid in Bean:

private HtmlDataGrid iFussDataGrid;

它的getter和setter

Its getter and setter

public HtmlDataGrid getiFussDataGrid() {
        return iFussDataGrid;
    }



 public void setiFussDataGrid(HtmlDataGrid iFussDataGrid) {
            this.iFussDataGrid = iFussDataGrid;
        }

现在在Bean中定义其动作侦听器,该侦听器将在按下命令按钮进行搜索时调用:

Now define its action listener in Bean which will invoke on pressing command button for search :

 public void resetDataScroller(ActionEvent e) {
               if(iFussDataGrid != null) {
                   iFussDataGrid.setFirst(0);
               }
          }

在命令按钮上调用ActionListener

Invoke ActionListener on command button

<h:commandButton styleClass="submit-button" actionListener="#{IFussBean.resetDataScroller}" action="#{IFussBean.searchLocation}" image="images/submit-button.png"/>

它也给欲望结果.

这篇关于t:dataScroller在刷新时无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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