2

I'm trying to use a4j:poll component for ajax reloading a datatable after some time interval. It's working fine, but when the table is automatically reloaded and I use the tools (edit/delete row) in the last column, datatable (all the rows) disappears and I have to load it manually (using h:commandButton)..

Here's part of my code:

<h:form>
  <a4j:poll id="poll" interval="30000" action="#{bean.load}" enabled="#{bean.pollEnabled}" render="list" />
</h:form>

<h:form id="list" ...>
 <rich:dataTable id="table" var="item" value="#{bean.model}">
 ...

A button which is calling the same load method:

  <h:commandButton id="btn" action="#{bean.load}" ... /> 

When I reload it using button, I can use the tools in the last column. Don't you know why?

enter image description here

UPDATE:

  • seems that in first case (a4j:poll), when using edit/delete, constructor of the bean is called........
  • bean is @ViewScoped
gaffcz
  • 3,469
  • 14
  • 68
  • 108

1 Answers1

2

seems that in first case (a4j:poll), when using edit/delete, constructor of the bean is called

I don't do RichFaces, but I guess that this problem is in some way related to JSF issue 790 which causes the view state of other forms being lost during ajax requests initiated by a separate form (and indeed also causes reconstruction of the backing beans associated with the other forms). This is also described as point 7 of commandButton/commandLink/ajax action/listener method not invoked or input value not updated.

In your particular case, placing the <a4j:poll> in the same form as the table should solve the problem. I'm not sure why that was placed in a separate form in first place, but that seems just unnecessary.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • It was separated because it's reloading two separated forms (in real application). So I've thought it would be better to be separeted too :-) Anyway, it works much better inside a form, thanks again :-) – gaffcz Aug 24 '12 at 11:55