History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: RF-1133
Type: Bug Bug
Status: Closed Closed
Resolution: Done
Priority: Critical Critical
Assignee: Tsikhon Kuprevich
Reporter: henrik lindberg
Votes: 13
Watchers: 11
Operations

If you were logged in you would be able to see more operations.
RichFaces

rich:datascroller does not reset when data model is changed

Created: 16/Oct/07 07:56 PM   Updated: 20/Jun/08 08:45 AM
Component/s: docs updated
Affects Version/s: 3.1.1
Fix Version/s: 3.2.0

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Issue Links:
Duplicate
 
This issue is duplicated by:
RF-1048 datascroller: improvement in scroller... Major Closed

Affects: Documentation (Ref Guide, User Guide, etc.)

Sub-Tasks  All   Open   
 Sub-Task Progress: 
1. Code optimization Sub-task Sub-task Closed Closed Tsikhon Kuprevich  
2. Submitted parameters on decode() weren't verified correctly Sub-task Sub-task Closed Closed Tsikhon Kuprevich  
3. Add new attribute to test-application Sub-task Sub-task Closed Closed Aleksej Yanul  

 Description  « Hide
When the datamodel for a rich:dataTable is replaced with a new model the rich:datascroller still remembers its old page index.
Now, in order to make it work, I have to look up the UIData and set the index to 0 when I change the datamodel.

I would expect it to either be set to 0, or to the value of "first" attribute in the rich:dataTable when its model is changed.

This problem is blocking me from releasing my application - I have *many* affected datascrollers and doing the following for all of them would not be fun...

// how I reset the first value - perhaps there are beter ways to do this
String id = "spaceForm:content_list";
UIComponent comp = FacesContext.getCurrentInstance().getViewRoot().findComponent( id );
if(comp == null)
throw new IllegalArgumentException("Can not find component with id = '"+id+"'");
if(!(comp instanceof UIData))
throw new IllegalArgumentException("Id does not refer to a UIData instance");
UIData uidata = (UIData)comp;
uidata.setFirst(0);


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order:
Nick Belaevski [18/Oct/07 03:31 PM]
Actually, dataScroller works by setting "first" attribute of dataTable component. The issue is called by the fact that UIData class doesn't track models it uses so when the model has changed component still continues to use legacy "first" value pointing to non-existent rows.

As a variant I can suggest to implement PhaseListener so that it will traverse and reset all UIData instances in view before render_response phase using the follwoing reset criteria: "first" value is larger than a number of rows.

Nick Belaevski [18/Oct/07 03:33 PM]
Fixing this issue seems highly problematic as the only possibility for dataScroller to reset UIData is to do it in encodeBegin() method, however the data component it is attached to could have been already rendered by that time

Nick Belaevski [18/Oct/07 03:34 PM]
P.S. Please note that PhaseListener approach will not work in case of nested data tables or data tables nested inside another iteration components (a4j:repeat etc.)

henrik lindberg [18/Oct/07 08:10 PM]
Hm, not so happy about this.

Wouldn't it be possible to control the "first" of the UIData differently (for those that need it)?

I have a proposal.

Why not add a "paginatorControl" attribute to the paginator - a bidirectional value binding that returns what you want the paginator to do:
- null or "" ; stay where you are (the default)
- "first", "last", "page-n" etc.

When the paginator has read the instruction and acts on it, it sets it to an empty strring.

This way it is very easy in a backing bean to control what to do when:
a) switching data model (set the control to "first")
b) adding a row and you want user to see it (set control to "last")

being able to do just a) would be sufficient for my needs right now, but would like to get "last" as well.

A very nice function to add would be a scroll into view action. If the string contains a number that means the index of the row to scroll into view (since it is more meaningful in the backing logic than a certain "pagenumber" as that requires the backing end to have knowledge about the number of items per page - which is a UI concern.

Having said all that - I realize that all that is needed is a value binding for an integer scrollITo. The value -1 would mean "do not change", and any other value means "scroll this index into view". Then it is possible to control, first, last, as well as making sure a newly added item in a sorted data model is brought into view, etc.

This would be soo much simpler to use than having to:
a) provide the "first" value as a property in the backing bean
b) lookup the page size in the UIData - alternatively control the pagesize with a property in the backing bean but then having the problem of recompiling code instead of modifying xhtml when changing the number of items to display on a page.
c) calculate the "first value" for "last" and "scroll to view" for other than first page
d) provide an onScroll method in the backing bean per paginator
e) add the call to onScroll in each paginator

contrast that with:
a) provide an int property per paginator
b) change it when needed in the backing bean
c) add the attibute scrollTo (or whatever it gets called) with a value binding

Should be fairly simple to implement is my guess, and my hopes are that you would consider adding something like this. I understand that the original request to reset the paginator on data model change is more complicated, I don't mind setting the value, but would like a convenient supported way of doing so.

Regards
- henrik

Nick Belaevski [30/Oct/07 12:49 PM]
Need to review the issue then. Maybe we can do something

Jacob Orshalick [13/Nov/07 12:57 PM]
I encountered this issue and implemented a workaround using a Seam interceptor that is described here:

http://solutionsfit.com/blog/2007/11/13/solution-using-seam-to-pagination-issue-with-jsf-on-datamodel-updates/

Hope it helps.

Nick Belaevski [13/Nov/07 01:12 PM]
Thank you!
We'll try to solve the issue at UI level only...

Floor FLUX [11/Mar/08 12:03 PM]
Implementation of Nick's Phase-Listener work-around proposal here:

http://blog.bluestonelabs.com/index.php/2008/03/11/phase-listener-solution-to-jsf-datascroller-pagination-problem/

Hope that helps.

Nick Belaevski [11/Mar/08 03:14 PM]
int "page" attribute added. If page >= 1 then it's a number of page to show, if page <= -1 then the page to show is pageCount + page + 1, so that if page="-1" the last page is shown

Svetlana mukhina [14/Mar/08 06:00 AM]
added in docs

Svetlana mukhina [23/May/08 10:01 AM]
docsupdated