You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/02/13 20:07:02 UTC
svn commit: r377465 - in
/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago:
component/Pager.java component/UIData.java model/SheetState.java
Author: weber
Date: Mon Feb 13 11:07:01 2006
New Revision: 377465
URL: http://svn.apache.org/viewcvs?rev=377465&view=rev
Log:
store first row in state
Modified:
incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Pager.java
incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SheetState.java
Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Pager.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Pager.java?rev=377465&r1=377464&r2=377465&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Pager.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Pager.java Mon Feb 13 11:07:01 2006
@@ -51,6 +51,7 @@
if (aobj[0] instanceof ActionEvent) {
UICommand command = (UICommand) ((ActionEvent) aobj[0]).getSource();
UIData data = (UIData) command.getParent();
+ int first = -1;
String action = (String)
command.getAttributes().get(ATTR_ACTION_STRING);
@@ -59,16 +60,16 @@
}
if (FIRST.equals(action)) {
- data.setFirst(0);
+ first = 0;
} else if (PREV.equals(action)) {
int start = data.getFirst() - data.getRows();
- data.setFirst(start < 0 ? 0 : start);
+ first = start < 0 ? 0 : start;
} else if (NEXT.equals(action)) {
int start = data.getFirst() + data.getRows();
int last = data.getLastPageIndex();
- data.setFirst(start > data.getRowCount() ? last : start);
+ first = start > data.getRowCount() ? last : start;
} else if (LAST.equals(action)) {
- data.setFirst(data.getLastPageIndex());
+ first = data.getLastPageIndex();
} else if (PAGE_TO_ROW.equals(action)) {
String startRow = (String) facesContext.getExternalContext()
.getRequestParameterMap().get(command.getClientId(
@@ -81,7 +82,7 @@
} else if (start < 0) {
start = 0;
}
- data.setFirst(start);
+ first = start;
} catch (NumberFormatException e) {
LOG.error("Catched: " + e.getMessage());
}
@@ -107,7 +108,7 @@
} else if (start < 0) {
start = 0;
}
- data.setFirst(start);
+ first = start;
} catch (NumberFormatException e) {
LOG.error("Catched: " + e.getMessage());
}
@@ -118,6 +119,10 @@
}
} else {
LOG.error("Unkown action: " + action);
+ }
+ if (first != -1) {
+ data.setFirst(first);
+ data.getSheetState(facesContext).setFirst(first);
}
data.queueEvent(new SheetStateChangeEvent(data));
Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIData.java?rev=377465&r1=377464&r2=377465&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIData.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIData.java Mon Feb 13 11:07:01 2006
@@ -18,13 +18,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_COLUMNS;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_WIDTH;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_LIST_STRING;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_HEADER;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH_LIST_STRING;
-import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_OUT;
+import static org.apache.myfaces.tobago.TobagoConstants.*;
import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
@@ -74,6 +68,10 @@
public void encodeBegin(FacesContext facesContext) throws IOException {
UILayout.prepareDimension(facesContext, this);
+ SheetState state = getSheetState(facesContext);
+ if (state.getFirst() > -1 && state.getFirst() < getRowCount()) {
+ setFirst(state.getFirst());
+ }
super.encodeBegin(facesContext);
}
@@ -278,7 +276,7 @@
public int getPage() {
int first = getFirst() + 1;
- int rows = getRows();
+ int rows = getRows();
if ((first % rows) > 0) {
return (first / rows) + 1;
} else {
Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SheetState.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SheetState.java?rev=377465&r1=377464&r2=377465&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SheetState.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/model/SheetState.java Mon Feb 13 11:07:01 2006
@@ -28,6 +28,7 @@
private static final Log LOG = LogFactory.getLog(SheetState.class);
public static final String SEPARATOR = ",";
+ private int first = -1;
private int sortedColumn = -1;
private boolean ascending;
private String columnWidths;
@@ -71,5 +72,13 @@
public void setColumnWidths(String columnWidths) {
this.columnWidths = columnWidths;
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public void setFirst(int first) {
+ this.first = first;
}
}