Oracle ADF Table Scrolling to Last Row:
package view;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.context.AdfFacesContext;
import oracle.jbo.NavigatableRowIterator;
import oracle.jbo.Row;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;
import org.apache.myfaces.trinidad.model.CollectionModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
public class testBean {
private RichTable empTable;
public testBean() {
}
public String b1_action() {
CollectionModel tableModel = (CollectionModel)getEmpTable().getValue();
JUCtrlHierBinding adfModel = (JUCtrlHierBinding)tableModel.getWrappedData();
DCIteratorBinding dciter = adfModel.getDCIteratorBinding();
NavigatableRowIterator nav=dciter.getNavigatableRowIterator();
//Row newRow = nav.createRow();
//newRow.setNewRowState(Row.STATUS_INITIALIZED);
Row lastRow = nav.last();
int lastRowIndex = nav.getRangeIndexOf(lastRow);
//nav.insertRowAtRangeIndex(lastRowIndex+1, newRow);
dciter.setCurrentRowWithKey(lastRow.getKey().toStringFormat(true));
return null;
}
public String b2_action() {
CollectionModel tableModel = (CollectionModel)getEmpTable().getValue();
JUCtrlHierBinding adfModel = (JUCtrlHierBinding)tableModel.getWrappedData();
DCIteratorBinding dciter = adfModel.getDCIteratorBinding();
NavigatableRowIterator nav=dciter.getNavigatableRowIterator();
Row lastRow = nav.last();
int lastRowIndex = nav.getRangeIndexOf(lastRow);
this.empTable.setRowIndex(lastRowIndex);
//this.tableBinding.setRowIndex(rowIndex);
RowKeySet ps = this.empTable.getSelectedRowKeys();
ps.clear();
ps.add(this.empTable.getRowKey());
AdfFacesContext.getCurrentInstance().addPartialTarget(this.empTable);
return null;
}
public void setEmpTable(RichTable empTable) {
this.empTable = empTable;
}
public RichTable getEmpTable() {
return empTable;
}
}
package view;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.context.AdfFacesContext;
import oracle.jbo.NavigatableRowIterator;
import oracle.jbo.Row;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;
import org.apache.myfaces.trinidad.model.CollectionModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
public class testBean {
private RichTable empTable;
public testBean() {
}
public String b1_action() {
CollectionModel tableModel = (CollectionModel)getEmpTable().getValue();
JUCtrlHierBinding adfModel = (JUCtrlHierBinding)tableModel.getWrappedData();
DCIteratorBinding dciter = adfModel.getDCIteratorBinding();
NavigatableRowIterator nav=dciter.getNavigatableRowIterator();
//Row newRow = nav.createRow();
//newRow.setNewRowState(Row.STATUS_INITIALIZED);
Row lastRow = nav.last();
int lastRowIndex = nav.getRangeIndexOf(lastRow);
//nav.insertRowAtRangeIndex(lastRowIndex+1, newRow);
dciter.setCurrentRowWithKey(lastRow.getKey().toStringFormat(true));
return null;
}
public String b2_action() {
CollectionModel tableModel = (CollectionModel)getEmpTable().getValue();
JUCtrlHierBinding adfModel = (JUCtrlHierBinding)tableModel.getWrappedData();
DCIteratorBinding dciter = adfModel.getDCIteratorBinding();
NavigatableRowIterator nav=dciter.getNavigatableRowIterator();
Row lastRow = nav.last();
int lastRowIndex = nav.getRangeIndexOf(lastRow);
this.empTable.setRowIndex(lastRowIndex);
//this.tableBinding.setRowIndex(rowIndex);
RowKeySet ps = this.empTable.getSelectedRowKeys();
ps.clear();
ps.add(this.empTable.getRowKey());
AdfFacesContext.getCurrentInstance().addPartialTarget(this.empTable);
return null;
}
public void setEmpTable(RichTable empTable) {
this.empTable = empTable;
}
public RichTable getEmpTable() {
return empTable;
}
}
public void testScrollingToLastRow() {
ViewObjectImpl vo = this.getEmployeesView1();
int pagesCount = vo.getEstimatedRangePageCount();
vo.scrollToRangePage(pagesCount);
Row lastRow = vo.getRowAtRangeIndex(vo.getRowCountInRange()-1);
System.out.println(lastRow.getAttribute(0));
}
No comments:
Post a Comment