This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
10 Replies Last post: Dec 5, 2007 9:52 AM by jimmy6  
jimmy6   44 posts since
Jul 12, 2007
Currently Being Moderated

Nov 27, 2007 10:30 AM

datatable sorting call backing bean method

1)I found that when i am using the sorting in datatable the FacesContext.getCurrentInstance().getRenderResponse() will not return true in the following phase. Why?

INFO 27-11-07 16:20:21 : BEFORE RENDER_RESPONSE(6) (http-80-Processor23)

 

2) How to call q_refreshTable('form2:woStatusChangeTable',null , 'woEditBean.refreshWoStatusTable')  in sorting or pagination? Because i want to call refreshWoStatusTable() to query data.

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
1. Nov 27, 2007 2:55 PM in response to: jimmy6
Re: datatable sorting call backing bean method

Hello Jimmy,

 

For our records I need to know your QuipuKit license details. Could you please send it to quipukit-support AT teamdev DOT com? I understand you are the registered customer, is it correct?

 

Thanks a lot.

 

Regards,

Tatyana

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
3. Nov 28, 2007 2:51 PM in response to: jimmy6
Re: datatable sorting call backing bean method

Hello Jimmy,

 

Yes, registered customers can post in this forum.

 

Regarding your first questions. According to JSF documentation ( http://java.sun.com/javaee/5/docs/api/javax/faces/context/FacesContext.html ), getRendereResponce() method returns true if the renderResponse() method has been called for the current request. So, the behavior you described is a standard behavior for JSF and not related to QuipuKit. Please describe the scenario that you are having problem with so that we can think of the possible solutions.

 

Regarding your second question. There is no possibility to call q_refreshTable() method when sorting or pagination is performed. Can you please describe your use case in detail so we can provide some solution without calling the q_refreshTable method?

 

Regards,

Tatyana

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
5. Nov 29, 2007 10:50 PM in response to: jimmy6
Re: datatable sorting call backing bean method

Hello,

 

Let me describe the problem as I understand it. There's rich:modalPanel with an embedded q:dataTable on the page. The modal panel is hidden by default, and it should be displayed by a "Show" button. If I understand the problem correctly you need the dataTable's data to be read from the database (or other underlying storage) only once when the user clicks the "Show" button, and then be able to view, sort and filter that data without any additional database queries. If my understanding of the problem is correct then it is possible to solve this as follows. Although q:dataTable will read the collection bound to its "value" attribute on any request anyway, it's possible to bind the "value" attribute to a method that will just return the value of a session-scope collection that is empty by default. The "Show" button handler can do the following to read the data table's data and show the modal panel:

  - execute the server action (with Ajax), which will read the requird data from the database and assign it to the session-scope variable that is bound to the data table;

  - reload the data table, which will now read the updated version of the session-scope variable;

  - show the modal panel.

The first two points can be implemented using the q_refreshTable JavaScript function, which allows both executing a server action and reloading a data table in one call. See the documentation for details.

 

So in brief it is not possible to avoid q:dataTable evaluating its "value" attribute binding on each request (showing a page, sorting, etc.), but it is possible to control the actual database queries by binding q:dataTable to an intermediate session-scope variable and control that variable's state explicitly. Please let us know if this approach solves your problem or if you are having any problems implementing it.

 

As to your second question regarding the getRenderResponse() method, we've double-checked its behavior on the "render response" phase in both QuipuKit data table and the standard h:dataTable and it appears to behave the same regardless of the component, which is consistent with what the JavaDoc for this method states. So according to our investigation, it is not correct to detect the "render response" phase using this method -- it will only return true if FacesContext.renderResponse method has been called in the same request. E.g. by default it happens when validation fails, or when reloading a page (with "GET" method). As an alternative, you can consider tracking the "render response" phase using phase listener.

 

Feel free to write if you have any further questions.

 

Regards,

Dmitry

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
7. Dec 3, 2007 5:13 PM in response to: jimmy6
Re: datatable sorting call backing bean method

Hello,

 

Below are the two issues that should be addressed in order to resolve the described problem:

 

1. The problem of loading data from database only once per request can be solved by reading the data in the get method and caching it in request scope so that the further calls to get method return the cached data without any additional data fetches. This will make the data to be cached on "Apply Request Values" phase only. If you'd like the data to be read on "Render Response" phase only, you can do it by returning an empty collection in the get method in all cases except when the "Render Response" phase is active, which can be tracked by phase listener.

 

2. The problem of not loading the data until the container panel is shown can be solved as follows. You can bind an attribute which specifies whether modalPanel is visible or not to your request-scope backing bean. If rich:modalPanel component doesn't support this feature, you can simulate it using the <h:inputHidden> component, where you'll need to maintain its state using JavaScript code. As a result you'll be able to implement the get method to return an empty collection when the panel is hidden and read the data otherwise. Note that for the value of this attribute should be submitted to the server when the presses the "Show" button. This can be as part of the call to q_refreshTable function.

 

As a result of these two modifications the datatable will not query the database until the user presses the "Show" button, and will query database once per request (for sorting, filtering etc.) afterwards. Note that it's not possible to remove these once-per-request data fetches without caching the data in session scope because the DataTable component doesn't store the data itself and uses the "value" attribute to receive data instead.

 

Hope this helps.

 

Regards,

Dmitry

Dmitry Pikhulya TeamDev Ltd. 162 posts since
Jan 5, 2007
Currently Being Moderated
9. Dec 4, 2007 6:36 PM in response to: jimmy6
Re: datatable sorting call backing bean method

Hello,

 

Actually according to our investigation the getRenderResponse/renderResponse methods of javax.faces.context.FacesContext class work in the same way as they do without QuipuKit components -- please see my first two messages. The suggestion in the articule that you are referring to seems to be incorect if used as is, or it possibly requires some additional application configuration for this approach to work. Can you pinpoint the case where the getRenderResponse method works incorrectly with QuipuKit?

 

Regards,

Dmitry

More Like This

  • Retrieving data ...