Bug #1590: Avoid repeated calls to goToOrdersList

A mechanism for ignoring in a scope the calls to createBindings has
been added. When accessing from the entry point the page is been
created and the AnnotatedDataBinder created automatically will track
the created tab. So in these cases we must ignore createBindings
calls.
This commit is contained in:
Óscar González Fernández 2012-12-10 20:45:14 +01:00
parent f06a44d6e9
commit c8129cd292
3 changed files with 28 additions and 5 deletions

View file

@ -198,7 +198,25 @@ public class Util {
return (DataBinder) component.getVariable("binder", false);
}
private static final ThreadLocal<Boolean> ignoreCreateBindings = new ThreadLocal<Boolean>() {
protected Boolean initialValue() {
return false;
};
};
public static void executeIgnoringCreationOfBindings(Runnable action) {
try {
ignoreCreateBindings.set(true);
action.run();
} finally {
ignoreCreateBindings.set(false);
}
}
public static void createBindingsFor(org.zkoss.zk.ui.Component result) {
if (ignoreCreateBindings.get()) {
return;
}
AnnotateDataBinder binder = new AnnotateDataBinder(result, true);
result.setVariable("binder", binder, true);
markAsNotReloadedForThisRequest(result);

View file

@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.Validate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.libreplan.web.common.Util;
import org.libreplan.web.common.converters.IConverter;
import org.libreplan.web.common.converters.IConverterFactory;
import org.zkoss.zk.ui.Execution;
@ -283,20 +284,25 @@ public class EntryPointsHandler<T> {
return applyIfMatches(controller, matrixParams);
}
private <S> boolean applyIfMatches(S controller,
private <S> boolean applyIfMatches(final S controller,
Map<String, String> matrixParams) {
flagAlreadyExecutedInThisRequest();
Set<String> matrixParamsNames = matrixParams.keySet();
for (Entry<String, EntryPointMetadata> entry : metadata.entrySet()) {
EntryPointMetadata entryPointMetadata = entry.getValue();
final EntryPointMetadata entryPointMetadata = entry.getValue();
EntryPoint entryPointAnnotation = entryPointMetadata.annotation;
HashSet<String> requiredParams = new HashSet<String>(Arrays
.asList(entryPointAnnotation.value()));
if (matrixParamsNames.equals(requiredParams)) {
Object[] arguments = retrieveArguments(matrixParams,
final Object[] arguments = retrieveArguments(matrixParams,
entryPointAnnotation, entryPointMetadata.method
.getParameterTypes());
callMethod(controller, entryPointMetadata.method, arguments);
Util.executeIgnoringCreationOfBindings(new Runnable() {
public void run() {
callMethod(controller, entryPointMetadata.method,
arguments);
}
});
return true;
}
}

View file

@ -471,7 +471,6 @@ public class MultipleTabsPlannerController implements Composer,
@Override
public void goToOrdersList() {
// ordersTab.show();
getTabsRegistry().show(ordersTab);
}