动态 Richfaces dataTable、a​​jax4jsf 和 reRendering

发布于 2024-08-24 20:22:55 字数 462 浏览 8 评论 0原文

我有一个在 a4j:outputPanel 内部定义的丰富的 dataTable,并且它绑定到创建 HtmlDataTable 的会话范围支持 bean。就其本身而言,我的代码的这一部分工作正常,并且数据表看起来不错。

在页面的另一部分,有一些我创建为 a4j:commandLinks 的基本文本链接,单击这些链接时,应使用新的行和列数据重新呈现数据表。行数据更新正常,但列数据(标题文本、宽度等)则不然。

深入研究一下代码后,似乎在该表的重新渲染期间并未调用 HtmlDataTable 的支持 bean,但如果重新加载整个页面,则会重新渲染;所以看起来这只是 ajax4jsf/reRendering 部分在这里困扰着我。

有什么方法可以强制重新渲染过程使 dataTable 结构无效,以便它再次调用支持 bean 吗?

如果这有什么意义的话,我也在使用Seam;因此,如果能找到使用它的解决方案,那也会很有帮助。

谢谢!

I have a rich dataTable that's defined inside of an a4j:outputPanel, and that's bound to a session-scoped backing bean that creates the HtmlDataTable. By itself, that part of my code is working fine, and the dataTable looks good.

On another part of the page, there are some basic text links that I'm creating as a4j:commandLinks, and when those are clicked, the dataTable should be re-rendered with new row and column data. The row data's updating fine, but the column data (header text, width, etc.) isn't.

After digging around the code for a bit, it seems that the call to the backing bean for the HtmlDataTable isn't being made during the reRendering of that table, but it is reRendered if the whole page is reloaded; so it seems that it's just the ajax4jsf/reRendering portion that's biting me here.

Is there any way that I can force the reRender process to invalidate the dataTable structure so that it will call the backing bean again for it?

If it means anything, I'm also using Seam; so if there's a solution to be found using it, that'd be helpful, too.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瓜 2024-08-31 20:22:55

为了后代,我找到了解决方案:每当向我的操作侦听器 bean 发出 a4j 请求时,我都会让它告诉 dataTable-building bean 刷新其表。然后,该 bean 执行一个简单的 myDataTable.getParent().getChildren().remove(myDataTable)。此页面帮助我弄清楚了:http://www. coderanch.com/t/213312/JSF/java/dynamic-datatable-binding

For posterity's sake, I've found the solution: Whenever the a4j request is made to my action listener bean, I have it tell the dataTable-building bean to flush its table. That bean then does a simple myDataTable.getParent().getChildren().remove(myDataTable). This page helped me figure it out: http://www.coderanch.com/t/213312/JSF/java/dynamic-datatable-binding.

云朵有点甜 2024-08-31 20:22:55

在您的操作中,只需从上下文中删除会话范围的 bean 即可。

例如:

<a:commandLink action="#{someBean.perform}" value="Submit" reRender="myTable"/>

和操作:

@Name("someBean")
public class SomeBean {

  public void perform() {
    //do stuff

    Contexts.removeFromAllContexts("myBean");  
  }
}

否则,如果您的 dataTable 填充了列表,那么它可能就像调用 search() 或任何加载数据的方法一样简单。

In your action just remove the session scoped bean from your contexts.

For example:

<a:commandLink action="#{someBean.perform}" value="Submit" reRender="myTable"/>

and the action:

@Name("someBean")
public class SomeBean {

  public void perform() {
    //do stuff

    Contexts.removeFromAllContexts("myBean");  
  }
}

Othewrwise if your dataTable is populated with a list then it's probably as easy as just calling the search() or whatever method loads the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文