IDEMPIERE-1103 Zk: Grid View onPostSelectedRowChanged event is called twice.

This commit is contained in:
Heng Sin Low 2013-06-25 00:13:25 +08:00
parent e88f59fa02
commit 717c2ca808
1 changed files with 16 additions and 3 deletions

View File

@ -84,6 +84,8 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
private static final int MIN_NUMERIC_COL_WIDTH = 130; private static final int MIN_NUMERIC_COL_WIDTH = 130;
private static final String ATTR_ON_POST_SELECTED_ROW_CHANGED = "org.adempiere.webui.adwindow.GridView.onPostSelectedRowChanged";
private Grid listbox = null; private Grid listbox = null;
private int pageSize = DEFAULT_PAGE_SIZE; private int pageSize = DEFAULT_PAGE_SIZE;
@ -324,7 +326,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
} }
} else if (rowIndex == renderer.getCurrentRowIndex()){ } else if (rowIndex == renderer.getCurrentRowIndex()){
if (modeless && !renderer.isEditing()) if (modeless && !renderer.isEditing())
Events.echoEvent("onPostSelectedRowChanged", this, null); echoOnPostSelectedRowChanged();
return; return;
} else { } else {
if (renderer.isEditing()) { if (renderer.isEditing()) {
@ -348,15 +350,25 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
gridFooter.setVisible(true); gridFooter.setVisible(true);
} }
if (rowIndex >= 0 && pgIndex >= 0) { if (rowIndex >= 0 && pgIndex >= 0) {
Events.echoEvent("onPostSelectedRowChanged", this, null); echoOnPostSelectedRowChanged();
} }
} else { } else {
if (rowIndex >= 0) { if (rowIndex >= 0) {
Events.echoEvent("onPostSelectedRowChanged", this, null); echoOnPostSelectedRowChanged();
} }
} }
} }
/**
*
*/
protected void echoOnPostSelectedRowChanged() {
if (getAttribute(ATTR_ON_POST_SELECTED_ROW_CHANGED) == null) {
setAttribute(ATTR_ON_POST_SELECTED_ROW_CHANGED, Boolean.TRUE);
Events.echoEvent("onPostSelectedRowChanged", this, null);
}
}
/** /**
* set paging size * set paging size
* @param pageSize * @param pageSize
@ -567,6 +579,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
* Event after the current selected row change * Event after the current selected row change
*/ */
public void onPostSelectedRowChanged() { public void onPostSelectedRowChanged() {
removeAttribute(ATTR_ON_POST_SELECTED_ROW_CHANGED);
if (listbox.getRows().getChildren().isEmpty()) if (listbox.getRows().getChildren().isEmpty())
return; return;