component.getAttributes().remove(PARTIAL_UPDATE);
component.getAttributes().remove(UPDATE_HEADER);
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
if(component instanceof UIScrollableDataTable){
UIScrollableDataTable grid = (UIScrollableDataTable)component;
ExternalContext externalContext = context.getExternalContext();
String clientId = grid.getClientId(context);
boolean sorted = false;
Map<String, String> parameters = externalContext.getRequestParameterMap();
String s_id = clientId + ":si";
grid.resetReqRowsCount();
if(parameters.containsKey(s_id)){
String options = (String)parameters.get(s_id);
grid.setScrollPos(options);
if(options.length() > 0){
String[] si = options.split(",");
grid.setFirst(Integer.parseInt(si[1]));
component.getAttributes().put(ScrollableDataTableUtils.CLIENT_ROW_KEY, Integer.parseInt(si[3]));
}
}
composite.decode(context, component);
if(parameters.containsKey(clientId + ":sortColumn") &&
parameters.containsKey(clientId + ":sortStartRow") &&
parameters.containsKey(clientId + ":sortIndex")){
String sortColumn = (String)parameters.get(clientId + ":sortColumn");
int sortDataIndex = Integer.parseInt((String)parameters.get(clientId + ":sortIndex"));
Integer sortStartRow = Integer.valueOf((String)parameters.get(clientId + ":sortStartRow"));
String sortOrderString =
(String) parameters.get(clientId + ":sortOrder");
Boolean so = null;
if (sortOrderString != null && sortOrderString.length() > 0 ) {
sortOrderString = sortOrderString.toLowerCase();
if (sortOrderString.startsWith("a")) {
so = Boolean.TRUE;
} else if (sortOrderString.startsWith("d")){
so = Boolean.FALSE;
}
}
UIComponent column = grid.findComponent(sortColumn);
if(ColumnUtil.isSortable(column)){
sorted = true;
SortEvent sortEvent = new SortEvent(grid,sortColumn, grid.getRows(), sortDataIndex);
sortEvent.setProposedOrder(so);
sortEvent.setAttribute(ScrollableDataTableUtils.CLIENT_ROW_KEY,sortStartRow);
if (ajaxContext.isAjaxRequest()) {
sortEvent.setAttribute(PARTIAL_UPDATE, Boolean.TRUE);
sortEvent.setAttribute(UPDATE_HEADER, Boolean.TRUE);
}
sortEvent.queue();
}
}
if(parameters.containsKey(clientId + ":scroll") && !sorted){
String submitedState = (String)parameters.get(clientId + "_state_input");
if (submitedState != null) {
boolean isEmpty = true;
String [] values = submitedState.split(",");
for (int i = 0; i < values.length; i++) {
isEmpty = isEmpty && values[i].equals("");
}
int rows = 0;
int first = 0;
if(!isEmpty){
rows = Integer.parseInt(values[0]);
first = Integer.parseInt(values[1]);
ScrollEvent scrollEvent = new ScrollEvent(grid,rows,first);
scrollEvent.setAttribute(ScrollableDataTableUtils.CLIENT_ROW_KEY,Integer.valueOf(values[2]));
if (ajaxContext.isAjaxRequest()) {
scrollEvent.setAttribute(PARTIAL_UPDATE, Boolean.TRUE);
}
scrollEvent.queue();