>Hope this helps you figure out what to focus on though. 

Thanks for your response.  This gives me refined direction.

>I don't have any solutions for you, since I always load the full data set
into the table.
This is also the approach I have taken, but that isn't an option anymore as
memory has become an issue.

Has anybody else had success in positioning to the middle of an SQL result
set and appropriately conveying that in the datascroller tag?

>> My version of MyFaces is 1.0.7
>>
>This really isn't supported anymore.

If a newer version had the capabilities I need then I could justify the
upgrade, but until then I cannot :-(


Aaron Bartell
http://mowyourlawn.com

-----Original Message-----
From: Jeff Bischoff [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 07, 2006 12:42 PM
To: MyFaces Discussion
Subject: Re: DataScroller - current page?

Albartell,

 > My version of MyFaces is 1.0.7
 >

This really isn't supported anymore.

As for your question, when rendering the dataScroller looks at the "first"
attribute of the dataTable. I suspect that since you are limiting the
dataset to 25, "first" always points to the first element on the list and
thus it logically thinks it is on the first page.

I don't have any solutions for you, since I always load the full data set
into the table. Hope this helps you figure out what to focus on though.

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

albartell wrote:
> I am trying to come up with a solution to large datasets by only 
> loading 25 records at a time.  I have looked at 
> <http://wiki.apache.org/myfaces/WorkingWithLargeTables>
> http://wiki.apache.org/myfaces/WorkingWithLargeTables but am having a 
> problem with the DataScroller component displaying the correct page 
> when I try to position to a particular page within the result.
>  
> So here's the scenario.  Admin logs in.  Admin displays list of users 
> 1 through 25.  Admin hits page 2 in data scroller. Admin choses to 
> edit a user on the second page which takes them to the edit page. Admin
selects 'SAVE'
> button and is returned to the user list page.  The data in the result 
> is correct in that it is showing the second page, but the datascroller 
> states it is on the first page (i.e. number 1 is bold between the 
> forward/backward arrows and it is displaying 1 of 10 vs. 2 of 10 as it
should be displaying).
>  
>  
> I have the following method named getUserListDataModel that provides 
> the 25 records at a time.  I believe what is happening is that when I 
> leave the user list page and come back the datascroller component is 
> re-initializing itself.  Is there a way to tell it that it is on the 
> 2nd page vs. the first page?
>  
> My version of MyFaces is 1.0.7
>  
> public class UcerController{
>     private int userListCurPage = 1;
>     private int userListCurStart = 1;
> ...
>     public DataModel getUserListDataModel() {
>         
>         HtmlDataTable data2 = (HtmlDataTable) 
> UIHelper.findComponent("form1:data2");
>         HtmlForm form1 = (HtmlForm) UIHelper.findComponent("form1");
>  
>         if (form1.isSubmitted())
>             firstResult = data2.getFirst();
>  
>         int rowCount = DAOGeneric.getDataCount("User", "");
>         List rows = DAOGeneric.getPagedData("User", "", orderBy, 
> orderDirection, firstResult, perPage);
>  
>         PagedListDataModel dataModel = new PagedListDataModel();
>         dataModel.setWrappedData(rows);
>         dataModel.setTotalNumRows(rowCount);
>         dataModel.setPageSize(perPage);
>         return dataModel;
>     }
>  
> ...
> }
>  
>  
> <h:panelGroup>
>  <x:dataTable id="data2"
>    styleClass="table" headerClass="table_header"
>    var="user" value="#{UserCtl.userListDataModel}"
>    preserveDataModel="true" 
>    rowClasses="row1,row2"
>    rows="25" >
>   <h:column>
>    <f:facet name="header">
>      <h:commandLink action="#{UserCtl.orderByName}">
>       <h:outputText id="orderbyname" value="#{fl.user_name}"/>
>      </h:commandLink> 
>    </f:facet>
>    <h:outputText value="#{user.name}" styleClass="copy"/>    
>   </h:column>      
>   <h:column>
>    <f:facet name="header">
>      <h:commandLink action="#{UserCtl.orderByFirstName}">
>       <h:outputText id="orderbyfirstname" value="First Name"/>
>      </h:commandLink> 
>    </f:facet>
>    <h:outputText value="#{user.firstname}" styleClass="copy"/>    
>   </h:column>        
>   <h:column>
>    <f:facet name="header">
>      <h:commandLink action="#{UserCtl.orderByLastName}">
>       <h:outputText id="orderbylastname" value="Last Name"/>
>      </h:commandLink> 
>    </f:facet>
>    <h:outputText value="#{user.lastname}" styleClass="copy"/>    
>   </h:column>      
>   <h:column>
>    <f:facet name="header">
>      <h:commandLink action="#{UserCtl.orderByEmail}">
>       <h:outputText id="orderbyemail" value="Email"/>
>      </h:commandLink> 
>    </f:facet>
>    <h:outputText value="#{user.email}" styleClass="copy"/>    
>   </h:column>                          
>   <h:column>
>    <f:facet name="header">
>     <h:outputText value="Action"/>
>    </f:facet> 
>    <h:commandLink id="edit" action="#{UserCtl.updateUserPage}"
value="edit"
> styleClass="copy"/>
>    <h:outputText value=" | " styleClass="copy"/>
>    <h:commandLink id="delete" action="#{UserCtl.deleteUserPage}"
> value="delete" styleClass="copy"/> 
>   </h:column>
>  </x:dataTable>
>  
>  <h:panelGrid columns="1" styleClass="table3">
>   <x:dataScroller id="ds2"
>     for="data2"
>     paginator="true"
>     paginatorMaxPages="9"
>     paginatorTableClass="paginator"
>     paginatorActiveColumnStyle="font-weight:bold;"                   
>     fastStep="10">
>    <f:facet name="first">
>     <h:graphicImage url="images/arrow-first.gif" styleClass="button" />
>    </f:facet>
>    <f:facet name="last">
>     <h:graphicImage url="images/arrow-last.gif" styleClass="button" />
>    </f:facet>
>    <f:facet name="previous">
>     <h:graphicImage url="images/arrow-previous.gif" styleClass="button" />
>    </f:facet>
>    <f:facet name="next">
>     <h:graphicImage url="images/arrow-next.gif" styleClass="button" />
>    </f:facet>
>    <f:facet name="fastforward">
>     <h:graphicImage url="images/arrow-ff.gif" styleClass="button" />
>    </f:facet>
>    <f:facet name="fastrewind">
>     <h:graphicImage url="images/arrow-fr.gif" styleClass="button" />
>    </f:facet>
>   </x:dataScroller>
>   <x:dataScroller  
>     for="data2"
>     pageCountVar="pageCount"
>     pageIndexVar="pageIndex">
>    <h:outputFormat value="#{controls['dataScroller_pages']}"
> styleClass="copy" >
>     <f:param value="#{pageIndex}" />
>     <f:param value="#{pageCount}" />
>    </h:outputFormat>
>   </x:dataScroller>
>  </h:panelGrid>
> </h:panelGroup>
> 
>  
>  
> import java.util.List;
> import javax.faces.model.DataModel;
>  
> public class PagedListDataModel extends DataModel {
>  
>     private int rowIndex = -1;
>     private int totalNumRows;
>     private int pageSize;
>     private List list;
>  
>     public PagedListDataModel() {
>         super();
>     }
>  
>     public PagedListDataModel(List list, int totalNumRows, int pageSize) {
>         super();
>         setWrappedData(list);
>         this.totalNumRows = totalNumRows;
>         this.pageSize = pageSize;
>     }
>  
>     public boolean isRowAvailable() {
>         if (list == null)
>             return false;
>  
>         int rowIndex = getRowIndex();
>         if (rowIndex >= 0 && rowIndex < list.size())
>             return true;
>         else
>             return false;
>     }
>  
>     public int getRowCount() {
>         return totalNumRows;
>     }
>  
>     public Object getRowData() {
>         if (list == null)
>             return null;
>         else if (!isRowAvailable())
>             throw new IllegalArgumentException();
>         else {
>             int dataIndex = getRowIndex();
>             return list.get(dataIndex);
>         }
>     }
>  
>     public int getRowIndex() {
>         return (rowIndex % pageSize);
>     }
>  
>     public void setRowIndex(int rowIndex) {
>         this.rowIndex = rowIndex;
>     }
>  
>     public Object getWrappedData() {
>         return list;
>     }
>  
>     public void setWrappedData(Object list) {
>         this.list = (List) list;
>     }
>  
>     public int getPageSize() {
>         return pageSize;
>     }
>  
>     public void setPageSize(int pageSize) {
>         this.pageSize = pageSize;
>     }
>  
>     public int getTotalNumRows() {
>         return totalNumRows;
>     }
>  
>     public void setTotalNumRows(int totalNumRows) {
>         this.totalNumRows = totalNumRows;
>     }
> }
> 


Reply via email to