Forums de discussion
LazyDataModel load wrong
Canh Minh Nguyen, modifié il y a 12 années.
LazyDataModel load wrong
New Member Publications: 11 Date d'inscription: 11/05/09 Publications récentes
When use ice:datapaginator, LazyDataModel load wrong when click next page, i changed code to fix this error
in class LazyDataModel
must change to
in class LazyDataModel
/**
* @see {@link javax.faces.model.DataModel#setRowIndex(int)}
*/
@Override
public void setRowIndex(int rowIndex) {
// If the specified rowIndex is outside the range of cached rows, then clear the cache so that the
// findRows(int startRow, int finishRow) method will be called in order to load the set of rows
// associated with the specified rowIndex.
if (rowIndex >= 0) {
int wrappedDataStartRowIndex = getWrappedDataStartRowIndex();
int wrappedDataFinishRowIndex = getWrappedDataFinishRowIndex();
if ((wrappedDataStartRowIndex >= 0) && (wrappedDataFinishRowIndex >= 0)) {
[color=#FF0000]int wrappedDataMaxFinishRowIndex = wrappedDataStartRowIndex + getRowsPerPage();[/color]
if ((rowIndex < wrappedDataStartRowIndex) || (rowIndex > wrappedDataMaxFinishRowIndex)) {
if (logger.isDebugEnabled()) {
logger.debug("rowIndex=[" + rowIndex + "] outside the range of cached rows so clearing cache");
}
reset();
}
}
}
this.rowIndex = rowIndex;
}
must change to
/**
* @see {@link javax.faces.model.DataModel#setRowIndex(int)}
*/
@Override
public void setRowIndex(int rowIndex) {
// If the specified rowIndex is outside the range of cached rows, then clear the cache so that the
// findRows(int startRow, int finishRow) method will be called in order to load the set of rows
// associated with the specified rowIndex.
if (rowIndex >= 0) {
int wrappedDataStartRowIndex = getWrappedDataStartRowIndex();
int wrappedDataFinishRowIndex = getWrappedDataFinishRowIndex();
if ((wrappedDataStartRowIndex >= 0) && (wrappedDataFinishRowIndex >= 0)) {
[color=#FF0303]int wrappedDataMaxFinishRowIndex = wrappedDataStartRowIndex + getRowsPerPage()[b] - 1[/b][/color];
if ((rowIndex < wrappedDataStartRowIndex) || (rowIndex > wrappedDataMaxFinishRowIndex)) {
if (logger.isDebugEnabled()) {
logger.debug("rowIndex=[" + rowIndex + "] outside the range of cached rows so clearing cache");
}
reset();
}
}
}
this.rowIndex = rowIndex;
}
Neil Griffin, modifié il y a 12 années.
RE: LazyDataModel load wrong
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Is this for data that is coming from a Liferay service API? You know, something like UserLocalServiceUtil.getUsers(...)?
If so, then you need to know that Liferay has a weird thing going on with it's results from services. It has a zero-relative start row, but a one-relative finish row.
Check out the following class:
https://github.com/liferay/liferay-faces/blob/master/demos/portal/icefaces3-documents-portlet/src/main/java/org/portletfaces/liferay/documents/list/DocumentDataModel.java
And then search for "includeFinishRowToo" to see what I mean.
If so, then you need to know that Liferay has a weird thing going on with it's results from services. It has a zero-relative start row, but a one-relative finish row.
Check out the following class:
https://github.com/liferay/liferay-faces/blob/master/demos/portal/icefaces3-documents-portlet/src/main/java/org/portletfaces/liferay/documents/list/DocumentDataModel.java
And then search for "includeFinishRowToo" to see what I mean.
Canh Minh Nguyen, modifié il y a 12 années.
RE: LazyDataModel load wrong
New Member Publications: 11 Date d'inscription: 11/05/09 Publications récentes
Hello Neil Griffin!
For example:
wrappedDataStartRowIndex = 0;
rowsPerPage = 20;
rowIndex = 20;// start row of second list
=> wrappedData is not reset and second page wrong
tell me if I'm wrong.
For example:
wrappedDataStartRowIndex = 0;
rowsPerPage = 20;
rowIndex = 20;// start row of second list
int wrappedDataStartRowIndex = getWrappedDataStartRowIndex();
int wrappedDataFinishRowIndex = getWrappedDataFinishRowIndex();
if ((wrappedDataStartRowIndex >= 0) && (wrappedDataFinishRowIndex >= 0)) {
int wrappedDataMaxFinishRowIndex = wrappedDataStartRowIndex + getRowsPerPage(); [color=#FA0606]// wrappedDataMaxFinishRowIndex = 20[/color]
if ((rowIndex < wrappedDataStartRowIndex) || (rowIndex > wrappedDataMaxFinishRowIndex)) {
if (logger.isDebugEnabled()) {
logger.debug("rowIndex=[" + rowIndex + "] outside the range of cached rows so clearing cache");
}
reset();
}
}
=> wrappedData is not reset and second page wrong
tell me if I'm wrong.
Neil Griffin, modifié il y a 12 années.
RE: LazyDataModel load wrong
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
You're right! Thanks!
http://issues.liferay.com/browse/FACES-11
LazyDataModel not resetting wrapped data due to incorrect wrappedDataMaxFinishRowIndex
http://issues.liferay.com/browse/FACES-11
LazyDataModel not resetting wrapped data due to incorrect wrappedDataMaxFinishRowIndex