Bug #1590: Fix problem calling several times the same method in OrderModel
The problem was that OrderModel.getOrders() was been called several times to show the list of projects. After reviewing the problem several issues were detected: * Util.createBindingsFor was always calling .loadAll() for each binder it creates, however this was not needed. Moreover a lot of times Util.reloadBindings is called just after Util.createBindings so the same thing is called twice. * If you go via the entry point or the icon to the project list, the binder for the page is properly initialized or not. If you come from the entry point, the binder is already working as expected, however if you come from the icon the binder has to be created manually. It has been added a method CreatedOnDemandTab.afterCreateAction() that is called or not depending if the user comes from the entry point or the icon. FEA: ItEr77S04BugFixing
This commit is contained in:
parent
5a76e6281e
commit
7ca0d43883
8 changed files with 63 additions and 8 deletions
|
|
@ -65,10 +65,23 @@ public class TabsRegistry {
|
|||
show(tab, DO_NOTHING);
|
||||
}
|
||||
|
||||
public void showWithoutAfterCreate(ITab tab) {
|
||||
show(tab, DO_NOTHING, false);
|
||||
}
|
||||
|
||||
public void show(ITab tab, IBeforeShowAction beforeShowAction) {
|
||||
show(tab, beforeShowAction, true);
|
||||
}
|
||||
|
||||
private void show(ITab tab, IBeforeShowAction beforeShowAction,
|
||||
boolean afterCreate) {
|
||||
hideAllExcept(tab);
|
||||
beforeShowAction.doAction();
|
||||
tab.show();
|
||||
if (afterCreate) {
|
||||
tab.show();
|
||||
} else {
|
||||
tab.showWithoutAfterCreate();
|
||||
}
|
||||
parent.invalidate();
|
||||
activateMenuIfRegistered(tab);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public interface ITab {
|
|||
|
||||
void show();
|
||||
|
||||
void showWithoutAfterCreate();
|
||||
|
||||
void hide();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ public class TabProxy implements ITab {
|
|||
proxiedTab.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWithoutAfterCreate() {
|
||||
proxiedTab.showWithoutAfterCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCssClass() {
|
||||
return proxiedTab.getCssClass();
|
||||
|
|
|
|||
|
|
@ -111,20 +111,28 @@ public class Util {
|
|||
return (DataBinder) component.getVariable("binder", false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void createBindingsFor(org.zkoss.zk.ui.Component result) {
|
||||
createBindingsFor(result, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void createBindingsFor(org.zkoss.zk.ui.Component result,
|
||||
boolean loadBindings) {
|
||||
List<org.zkoss.zk.ui.Component> children = new ArrayList<org.zkoss.zk.ui.Component>(
|
||||
result.getChildren());
|
||||
for (org.zkoss.zk.ui.Component child : children) {
|
||||
createBindingsFor(child);
|
||||
}
|
||||
setBinderFor(result);
|
||||
setBinderFor(result, loadBindings);
|
||||
}
|
||||
|
||||
private static void setBinderFor(org.zkoss.zk.ui.Component result) {
|
||||
private static void setBinderFor(org.zkoss.zk.ui.Component result,
|
||||
boolean loadBindings) {
|
||||
AnnotateDataBinder binder = new AnnotateDataBinder(result, true);
|
||||
result.setVariable("binder", binder, true);
|
||||
binder.loadAll();
|
||||
if (loadBindings) {
|
||||
binder.loadAll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,9 +72,21 @@ public class CreatedOnDemandTab implements ITab {
|
|||
|
||||
@Override
|
||||
public void show() {
|
||||
show(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWithoutAfterCreate() {
|
||||
show(false);
|
||||
}
|
||||
|
||||
private void show(boolean afterCreate) {
|
||||
beforeShowAction();
|
||||
if (component == null) {
|
||||
component = componentCreator.create(parent);
|
||||
if (afterCreate) {
|
||||
afterCreateAction(component);
|
||||
}
|
||||
}
|
||||
component.setParent(parent);
|
||||
afterShowAction();
|
||||
|
|
@ -90,6 +102,9 @@ public class CreatedOnDemandTab implements ITab {
|
|||
protected void beforeShowAction() {
|
||||
}
|
||||
|
||||
protected void afterCreateAction(Component component) {
|
||||
}
|
||||
|
||||
protected void afterShowAction() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ public class MultipleTabsPlannerController implements Composer,
|
|||
@Override
|
||||
public void goToOrdersList() {
|
||||
// ordersTab.show();
|
||||
getTabsRegistry().show(ordersTab);
|
||||
getTabsRegistry().showWithoutAfterCreate(ordersTab);
|
||||
}
|
||||
|
||||
public void goToCreateForm() {
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ public class OrdersTabCreator {
|
|||
args.put("orderController", setupOrderCrudController());
|
||||
result = Executions.createComponents("/orders/_ordersTab.zul",
|
||||
parent, args);
|
||||
Util.createBindingsFor(result);
|
||||
Util.reloadBindings(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -110,6 +108,11 @@ public class OrdersTabCreator {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterCreateAction(org.zkoss.zk.ui.Component component) {
|
||||
Util.createBindingsFor(component, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterShowAction() {
|
||||
orderCRUDController.goToList();
|
||||
|
|
|
|||
|
|
@ -140,4 +140,13 @@ public class TabOnModeType implements ITab {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWithoutAfterCreate() {
|
||||
beingShown = true;
|
||||
ITab currentTab = getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
currentTab.showWithoutAfterCreate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue