[richfaces-issues] [JBoss JIRA] Commented: (RF-1133) rich:datascroller does not reset when data model is changed

henrik lindberg (JIRA) jira-events at lists.jboss.org
Thu Oct 18 20:11:03 EDT 2007


    [ http://jira.jboss.com/jira/browse/RF-1133?page=comments#action_12383353 ] 
            
henrik lindberg commented on RF-1133:
-------------------------------------

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


> rich:datascroller does not reset when data model is changed
> -----------------------------------------------------------
>
>                 Key: RF-1133
>                 URL: http://jira.jboss.com/jira/browse/RF-1133
>             Project: RichFaces
>          Issue Type: Bug
>    Affects Versions: 3.1.1
>            Reporter: henrik lindberg
>         Assigned To: Nick Belaevski
>            Priority: Critical
>             Fix For: 3.2.0
>
>
> 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);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the richfaces-issues mailing list