-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'am trying to execute EL Expressions without current Execution (inside backgound job)
refer to ZK-4340 i'am create FakeExecution instance. Activates it and eval the expression. This works fine, but when i try to deactivate the execution it fails with a NullPointerException, because current session is null.
This looks like a bug. UiEngineImpl does not checks session for null.
Code example:
// Create fake exec
Execution exec = FakeExecution.getExecution(UiUtilsWebAppInit.getWebApp());
// Setup variable resolver
CtxVariableResolver resolver = null;
resolver = new CtxVariableResolver();
exec.addVariableResolver(resolver);
Evaluator ev = exec.getEvaluator((Page) null, null);
//Sets current fake execution as active
((WebAppCtrl) UiUtilsWebAppInit.getWebApp()).getUiEngine().activate(exec);
ev.evaluate((Page) null, ev.parseExpression(exp, expType));
// Deactivating desktop
((WebAppCtrl) UiUtilsWebAppInit.getWebApp()).getUiEngine().deactivate(exec);
Stack trace:
java.lang.NullPointerException: null
at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:2117) ~[zk-9.6.0.1.jar:9.6.0.1]
at org.zkoss.zk.ui.impl.UiEngineImpl.deactivate(UiEngineImpl.java:1927) ~[zk-9.6.0.1.jar:9.6.0.1]
at org.sinnlabs.dbvim.objects.ExpressionEvaluator.evaluate(ExpressionEvaluator.java:80) ~[dbvim-objects-0.2-SNAPSHOT.jar:?]
at org.sinnlabs.dbvim.objects.DBObject.initDefValues(DBObject.java:161) ~[dbvim-objects-0.2-SNAPSHOT.jar:?]
After ZK-4340 is fixed, you don't need to create your fake execution to create components in a working thread.
UiEngine.activate(exec)
is called when you need to access components. It seems it's no need to call it before evaluating an EL.
Since I am not familiar with what you are doing, if you can provide a runnable example, that will help us understand better.
Asked: 2021-12-08 00:22:41 +0800
Seen: 6 times
Last updated: Dec 08 '21