I figured out a way to do this, so I’ll post it in case anyone else needs to accomplish this same task:

 

1. Page displaying DataTable with DataScroller to scroll through large result set:

 

<t:dataTable  id=”data” value=”#(backingbean.datamodel)”

              rowIndexVar="rowindex"

              rows=”#{backingbean.displayrows}”

              first=”#{backingbean.pageindex}”

              rendered="#{backingbean.datamodel.rowCount > 0}"

              …… (snippet only)

 

//  command link to link to details page for selected row

<t:commandLink action="" immediate="true" >

     <h:outputText value="view details" />

      //  update pageindex property on backing bean with rowindex var from the datatable when commandlink is clicked

     <t:updateActionListener property="#{backingbean.pageindex}" value="#{rowindex}" />

</t:commandLink>

 

<t:dataScroller id="scroll_1" for="" fastStep="10" pageCountVar="pagecount" pageIndexVar="pageindex"

paginatorMaxPages="9" paginator="true"

rendered="#{backingbean.datamodel.rowCount > backingbean.displayrows}">

 

 

2.      Backing Bean for Page displaying the DataTable (session scope)

 

private int pageindex;  // keep track of page index within datascroller

private int displayrows;  // number of rows displayed in datascroller

 // constructor

 public BackingBean() {

    pageindex = 0;   // set initial page index to zero or first row in backingbean.datamodel

   displayrows=10;    }

 

// getters & setters – setter for pageindex is one of interest

//  setPageindex example:  displayrows=25; current rowindex =6;  ((62/25)*25) = 2*25 = 50 (first row of datascroller)

public void setPageindex(int rowindex) {  this.pageindex = ((rowindex/displayrows)* displayrows);  }

public int getPageindex() { return pageindex;  }

public int getDisplayrows() {  return displayrows; }

 

 

3.      Detail page (linked to from page containing datatable)

//  when return to datatable page, will be placed at same position within the datascroller

<h:commandButton action="" value="Return to DataTable Page" />  // navigation specified in faces-config.xml

 


From: Tom Butler [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 05, 2006 12:24 AM
To: users@myfaces.apache.org
Subject: returning to same position within a datascroller?

 

Is it possible to return to the same position within a datascroller after leaving the page and returning (i.e., datatable displays a large result set; user has scrolled through the data and is on the 3rd page of data; user selects a record which links them to a detail page; now want to return the user to the original .jsf page at the same 3rd page of data within the datascroller)?  If so, how?

 

thanks

Reply via email to