This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
8 Replies Last post: Apr 22, 2008 11:47 PM by Dmitry Pikhulya  
jan   5 posts since
Apr 17, 2008
Currently Being Moderated

Apr 17, 2008 11:12 PM

datatable loads only when we click an a4j:command button twice?

 

Hi,

 

 

Iam facing a problem..

 

 

 

 

I got a <q:datatable which gets re-rendered by an ajax call ..i.e on the click of an a4j:commandButton.... but the dataTable gets loaded only when the button is clicked twice... It happens only in some cases..The dataTable immediately gets re rendered on a single click only if  initially the datatable is present.. I use the rendered attribute for rendering the datatable..  If initially the datatable is renderd or present in the page,it gets rerendered on single clickof a button..but if its not present initially ..then u need to clcik the button twice to re render the table..

 

 

i tried enclsong the datatable in <a4j:outPutPanel> but it wasnt any use....

 

 

I hope my problem makes sense..

 

 

Please help..

 

 

 

 

Thanx

 

 

 

 

 

 

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
1. Apr 17, 2008 11:29 PM in response to: jan
Re: datatable loads only when we click an a4j:command button twice?

Hello,

 

This issue appears not to be specific to QuipuKit. Ajax4jsf cannot reload a component if it is initially not visible because it doesn't "know" where on the page a component should be loaded. More formally, you cannot change the "rendered" attribute of a component (a DataTable in this case), and rerender this component at the same time. The solution is to retain the functionality that manipulates the "rendered" attribute of your DataTable, but enclose the DataTable inside of <a4j:outputPanel> and rerender that output panel instead of data table. I suppose that the mistake in your case was that you tried to rerender the DataTable instead of output panel.

 

Please tell if this solves the problem.

 

Regards,

Dmitry

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
5. Apr 18, 2008 1:06 AM in response to: jan
Re: datatable loads only when we click an a4j:command button twice?

Your code snippet outlines the approach that I have mentioned correctly. Did you try replacing the &lt;q:dataTable&gt; by &lt;h:dataTable&gt; or any other component and manipulating its "rendered" attribute in a similar way? Please check whether this problem is specific to &lt;q:dataTable&gt;. Also, please double-check that there are no JavaScript errors or exceptions in the server's logs and let us know the results.

 

Dmitry

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
6. Apr 18, 2008 9:17 PM in response to: jan
Re: datatable loads only when we click an a4j:command button twice?

Hello,

 

First, let me describe how I understand the problem. You have a table with drop-down filtering on one of its columns, and a button, which rerenders this table using Ajax4jsf. First, you filter the table by one of the drop-down values, and then you try to reload tha table by pressing the "rerender" button. If I understand the problem correctly, the table gets reloaded -- it is still displayed as filtered by the selected filter value, but it contains the old row values as they were before the reloading, disregarding any changes that have been made in the underlying data storage. Is my understanding correct?

 

I have just tried the described scenario and everything worked fine. Please send us an example where we can reproduce the problem.

 

Dmitry

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
8. Apr 22, 2008 11:47 PM in response to: jan
Re: datatable loads only when we click an a4j:command button twice?

Hi,

 

Your situation as you describe it appears to actually reflect the proper behavior of DataTable if I understand you correctly. Refreshing the DataTable with Ajax4jsf is not supposed to remove filtering parameters. So if there are no records that satisfy the filtering criteria then the table will end up showing empty result set after refreshing, just like in your case. Then you remove the filtering value from a filtered column and the fresh data is displayed, which is also correct because there are no more filters to hide any records.

 

What behavior would you like to have? Would you like that the filtering parameter be removed when refreshing the table? If so, then you can implement this behavior by binding the column's filterValue attribute to a backing bean and clearing that bound value with a server action that should be executed along with Ajax4jsf refresh.

 

Dmitry

More Like This

  • Retrieving data ...