ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

MVEL resolving 3 Times

admin
21 Mar 2008 12:05:12 GMT
21 Mar 2008 12:05:12 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4855650

By: robertpic71

I am actually extend my JDBC-binding (actual: alpha statusfor annontations) to the expressions. I think JBDC-Bindung could be a good solution for small projects. However i have some troubles with the MVEL-Part:

Here is my example:
<?evaluator name="mvel"?>
<?variable-resolver class="org.zkforge.converters.JDBCResolver"?>

<window id="wnd" width="100%">
Status:
<combobox id="status">
<comboitem label="${each.name}" value="${each}"
forEach="${JDBC1.getSQL('select * from statuses')}" />
</combobox>
Actions:
<combobox id="actions">
<comboitem label="${each.name}" value="${each}"
forEach="${JDBC2.getSQL('select * from actions')}" />
</combobox>
</window>

Here is the Resolver:
...
public Object resolveVariable(String name) {
log.debug("Variable " + name);
try {
if (name.startsWith("JDBC")) {
/* TODO seperate JDBC-Source to the constructor
* none constructor is the default JDBC-Source (0)
* Note: JDBCBind handles the getSQL(String sql)
*/
return new JDBCBind();
} else {
// test the regular EL's
return new BindingResultSetModelList(sachbListDAO.getAllSachbEntriesRaw(),
true);
}
}
...

When i execute the zul the console shows 3xVariable JDBC1 3XVariable JDBC2 from the log.debug

When i change to the default EL-Egine, the resolver is called one time. But the EL do not support .getxxx('..').

I have testet 3.0.1 and 3.0.4 FL 2008-03-20.

/Robert


admin
25 Mar 2008 01:53:19 GMT
25 Mar 2008 01:53:19 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4861744

By: waterbottle

Hi,
I have some dump of variable resolver, and find the MVEL implementation did resolve the variable 3 time.

1st .

at java.lang.Thread.dumpStack(Thread.java:1158)
at boo.JDBCResolver.resolveVariable(JDBCResolver.java:41)
at org.zkoss.zk.ui.impl.PageImpl.resolveVariable(PageImpl.java:490)
at org.zkoss.zk.ui.impl.PageImpl.access$400(PageImpl.java:111)
at org.zkoss.zk.ui.impl.PageImpl$NS.getVariable(PageImpl.java:1206)
at org.zkoss.zk.scripting.util.SimpleNamespace.getVariable(SimpleNamespace.java
:93)
at org.zkoss.zk.ui.AbstractComponent.getVariable(AbstractComponent.java:738)
at org.zkoss.zk.xel.impl.ExecutionResolver.resolveVariable(ExecutionResolver.ja
va:147)
at org.zkoss.zkmax.xel.mvel.XelMVELResolver.isResolveable(XelMVELResolver.java:
61)
at org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:93)
at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java
:23)
at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:44)
at org.mvel.MVEL.executeExpression(MVEL.java:240)
at org.zkoss.zkmax.xel.mvel.MVELXelExpression.evaluate(MVELXelExpression.java:5
2)
at org.zkoss.zk.xel.impl.SimpleEvaluator.evaluate(SimpleEvaluator.java:71)

2nd.

at java.lang.Thread.dumpStack(Thread.java:1158)
at boo.JDBCResolver.resolveVariable(JDBCResolver.java:41)
at org.zkoss.zk.ui.impl.PageImpl.resolveVariable(PageImpl.java:490)
at org.zkoss.zk.ui.impl.PageImpl.access$400(PageImpl.java:111)
at org.zkoss.zk.ui.impl.PageImpl$NS.getVariable(PageImpl.java:1206)
at org.zkoss.zk.scripting.util.SimpleNamespace.getVariable(SimpleNamespace.java
:93)
at org.zkoss.zk.ui.AbstractComponent.getVariable(AbstractComponent.java:738)
at org.zkoss.zk.xel.impl.ExecutionResolver.resolveVariable(ExecutionResolver.ja
va:147)
at org.zkoss.zkmax.xel.mvel.XelMVELResolver.getVariableResolver(XelMVELResolver
.java:51)
at org.mvel.ast.VarPropertyNode.getReducedValueAccelerated(VarPropertyNode.java
:18)
at org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:107
)
at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java
:23)
at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:44)
at org.mvel.MVEL.executeExpression(MVEL.java:240)
at org.zkoss.zkmax.xel.mvel.MVELXelExpression.evaluate(MVELXelExpression.java:5
2)
at org.zkoss.zk.xel.impl.SimpleEvaluator.evaluate(SimpleEvaluator.java:71)

3rd.

at java.lang.Thread.dumpStack(Thread.java:1158)
at boo.JDBCResolver.resolveVariable(JDBCResolver.java:41)
at org.zkoss.zk.ui.impl.PageImpl.resolveVariable(PageImpl.java:490)
at org.zkoss.zk.ui.impl.PageImpl.access$400(PageImpl.java:111)
at org.zkoss.zk.ui.impl.PageImpl$NS.getVariable(PageImpl.java:1206)
at org.zkoss.zk.scripting.util.SimpleNamespace.getVariable(SimpleNamespace.java
:93)
at org.zkoss.zk.ui.AbstractComponent.getVariable(AbstractComponent.java:738)
at org.zkoss.zk.xel.impl.ExecutionResolver.resolveVariable(ExecutionResolver.ja
va:147)
at org.zkoss.zkmax.xel.mvel.XelMVELResolver$VarResolver.getValue(XelMVELResolve
r.java:129)
at org.mvel.ast.VarPropertyNode.getReducedValueAccelerated(VarPropertyNode.java
:18)
at org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:107
)
at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java
:23)
at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:44)
at org.mvel.MVEL.executeExpression(MVEL.java:240)
at org.zkoss.zkmax.xel.mvel.MVELXelExpression.evaluate(MVELXelExpression.java:5
2)
at org.zkoss.zk.xel.impl.SimpleEvaluator.evaluate(SimpleEvaluator.java:71)

check those 3 lines

org.zkoss.zkmax.xel.mvel.XelMVELResolver.isResolveable(XelMVELResolver.java:61)
org.zkoss.zkmax.xel.mvel.XelMVELResolver.getVariableResolver(XelMVELResolver.jav
a:51)
org.zkoss.zkmax.xel.mvel.XelMVELResolver$VarResolver.getValue(XelMVELResolver.ja
va:129)

will all invoke
org.zkoss.zk.xel.impl.ExecutionResolver.resolveVariable(ExecutionResolver.java:1
47)

I think since it is a variable resolver, you should add more control on the variable such as create only one instance for each variable.


/Dennis








admin
26 Mar 2008 23:18:55 GMT
26 Mar 2008 23:18:55 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4866053

By: robertpic71

Hi Dennis,

thanks for the hint. I have made an error in reasoning. I removed the caching-maps (i've copied the source from the jndi-resolver), because i was afraid, that would cache my JDBC-results. But only the Variable (in may case: JDBCBinder) is cached.

Now it work's as expected. Of course, mixing GUI and SQL-Code is only for quick&dirty devlopment, but i've never filled in combo- and listboxes with less code and definitions ;-)

Another question: Is there any standardclass for autocomplete/filtering (combobox)?
I've found the class org.zkoss.zkdemo.userguide.SimpleAutoComplete, but this is not part from the distribution binaries.

/Robert

BTW: you (and zk-team) doing a good job here in the forum