简体   繁体   English

rich:dataScroller不会刷新JSF中的rich:dataTable

[英]rich:dataScroller does not refresh rich:dataTable in JSF

I have a rich:dataTable and a rich:dataScroller. 我有一个rich:dataTable和一个rich:dataScroller。 When I click on the datascroller, my dataTable does not refresh automatically to show the correct page. 当我单击datascroller时,我的dataTable不会自动刷新以显示正确的页面。 If, however, I press the refresh button the dataTable shows the correct page. 但是,如果按刷新按钮,则dataTable将显示正确的页面。

What am I doing wrong? 我究竟做错了什么?

Here is my code: 这是我的代码:

<rich:dataTable id="applicantsTable"
binding="#{applicantListManBean.applicantsDataTable}"
value="#{applicantListManBean.applicantsList}" var="applicant"
rows="10" width="650">

<h:column>
    <f:facet name="header">
        <h:outputText value="Name" />
    </f:facet>
    <h:outputText value="#{applicant.name}" />
</h:column>

<h:column>
    <f:facet name="header">
        <h:outputText value="Email" />
    </f:facet>
    <h:outputText value="#{applicant.email}" />
</h:column>

<h:column>

    <f:facet name="header">
        <h:outputText value="Action" />
    </f:facet>

    <h:commandLink action="#{applicantListManBean.showApplicantProducts}"
        rendered="true">
        <h:graphicImage value="/images/icons/view.png" width="15" height="15"
            alt="view" />
        <f:setPropertyActionListener
            target="#{applicantListManBean.tempApplicant}" value="#{applicant}" />
    </h:commandLink>

    <h:commandLink action="#{applicantListManBean.deleteApplicant}"
        rendered="true">
        <h:graphicImage value="/images/icons/delete.png" width="15"
            height="15" alt="view" />
        <f:setPropertyActionListener
            target="#{applicantListManBean.tempApplicant}" value="#{applicant}" />
    </h:commandLink>

</h:column>
</rich:dataTable>

<rich:datascroller id="applicantsScroller" for="applicantsTable"
reRender="sc1" maxPages="7" page="#{applicantListManBean.scrollerPage}" />

UPDATE: Javascript error attached: 更新:附加的Javascript错误: 替代文字

1 : 1 http://imgur.com/132fL.png http://imgur.com/132fL.png

Remove reRender="sc1" . 删除reRender="sc1" You have copy-pasted this from the RichFaces demo, but you have removed the "sc1" component, so perhaps a javascript error occurs that prevents the table from refreshing. 您已经从RichFaces演示中复制粘贴了此内容,但是您删除了“ sc1”组件,因此可能发生了JavaScript错误,导致表格无法刷新。

Also make sure you have your dataTable and datascroller surrounded by <h:form>..</h:form> (both in one form) 还要确保您的dataTabledatascroller<h:form>..</h:form>包围(均为一种形式)

The problem is the h:commandLink. 问题是h:commandLink。 It somehow creates problems for the rich:datatable. 它以某种方式给rich:datatable带来了问题。 Use a4j:commandLink or s:link (if you use Jboss Seam) instead. 请改用a4j:commandLink或s:link(如果使用Jboss Seam)。

You may want to consider using t:saveState tag or putting the handler in session scope. 您可能要考虑使用t:saveState标记或将处理程序置于会话范围内。 The reason this is probably happening is because you have your handler in request scope and since the commandLink is another request, it cannot find the original handler instance to post back to. 发生这种情况的原因可能是因为您将处理程序置于请求范围内,并且因为commandLink是另一个请求,所以它找不到要发回的原始处理程序实例。 By simply having this saveState in here, mine started working. 通过在此简单地保存这个saveState,我的工作开始了。

Just a thought. 只是一个想法。

is wrong.. 是错的..

try: 尝试:

    <rich:dataTable width="300" id="carList" rows="10" columnClasses="col"
                        value="#{datosCtrlBean.datos}" var="category" >


            <rich:datascroller align="left" for="carList" id="sc2"  ajaxSingle="true" reRender="carList" limitToList="carList"/>

Put id for rich:datatable and reRender in rich:datascroller to table as shown below. rich:datatable id放入rich:datascroller并将reRender rich:datascroller表中,如下所示。 This works for me: 这对我有用:

<f:view>
    <a4j:keepAlive beanName="datosCtrlBean" ajaxOnly="true"/>
    <h:form>
        <rich:dataTable reRender="sc2"  width="300" id="carList" rows="10" columnClasses="col"
                            value="#{datosCtrlBean.datos}" var="category" id="myTable" >

                <f:facet name="header">
                    <rich:columnGroup>
                        <h:column>
                            <h:outputText styleClass="headerText" value="Make" />
                        </h:column>
                    </rich:columnGroup>
                </f:facet>
                <h:column>
                    <h:outputText value="#{category}" />
                </h:column>
                <f:facet name="footer">
                <rich:datascroller align="left" for="carList" id="sc2"  ajaxSingle="true" reRender="myTable" limitToList="myTable"/>
                </f:facet>
            </rich:dataTable>
    </h:form>
</f:view>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM