java rich:dataScroller 不刷新 Rich:dataTable 在 JSF 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1973711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rich:dataScroller does not refresh rich:dataTable in JSF
提问by Markos Fragkakis
I have a rich:dataTable and a rich:dataScroller. When I click on the datascroller, my dataTable does not refresh automatically to show the correct page. If, however, I press the refresh button the dataTable shows the correct page.
我有一个rich:dataTable 和一个rich:dataScroller。当我单击 datascroller 时,我的 dataTable 不会自动刷新以显示正确的页面。但是,如果我按下刷新按钮,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错误:

回答by Bozho
Remove 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.
删除reRender="sc1"。您已从 RichFaces 演示中复制粘贴此内容,但您已删除“sc1”组件,因此可能发生了 javascript 错误,导致表无法刷新。
Also make sure you have your dataTableand datascrollersurrounded by <h:form>..</h:form>(both in one form)
还要确保你有你的dataTable和datascroller包围<h:form>..</h:form>(都以一种形式)
回答by Markos Fragkakis
The problem is the h:commandLink. It somehow creates problems for the rich:datatable. Use a4j:commandLink or s:link (if you use Jboss Seam) instead.
问题是 h:commandLink。它以某种方式为富人带来了问题:数据表。请改用 a4j:commandLink 或 s:link(如果您使用 Jboss Seam)。
回答by user462230
You may want to consider using t:saveState tag or putting the handler in session scope. 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. By simply having this saveState in here, mine started working.
您可能需要考虑使用 t:saveState 标记或将处理程序放在会话范围内。这可能发生的原因是因为您的处理程序在请求范围内,并且由于 commandLink 是另一个请求,它找不到要回发的原始处理程序实例。通过简单地将这个 saveState 放在此处,我的就开始工作了。
Just a thought.
只是一个想法。
回答by user3712942
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"/>
回答by Hema
Put id for rich:datatableand reRenderin rich:datascrollerto table as shown below. This works for me:
将 id forrich:datatable和reRenderin放入rich:datascroller表中,如下所示。这对我有用:
<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>

