-
New Feature
-
Resolution: Done
-
Normal
-
9.0.0, 8.6.4
-
Security Level: Jimmy
-
ZK 9.5.0 S1
-
None
Steps to Reproduce
compare: calling a bean method via EL using a matching or non matching parameter type
1) calling concat(String)
<label value="${'asdf'.concat('astring')}"/>
2) calling concat(Long)
<label value="${'asdf'.concat(1234)}"/>
Current Result
case 1) will identify the method directly and invoke it efficiently
case 2) will fail to find the method initially throw/catch a MethodNotFound exception, and then loop through all available methods on the class until it finds a potential match
(this exception + loop happens every time)
Expected Result
ideally a matching method should be cached (if efficiently possible)
avoiding the exception and the loop
Debug Information
https://github.com/zkoss/zk/blob/v9.0.0/zel/src/org/zkoss/zel/BeanELResolver.java#L209-L222
Workaround
for the String.concat case use the concatenation '+=' operator
<label value="${'asdf' += 1234}"/> <!-- for data binding extra parentheses are required --> <label value="@init(('asdf' += 1234))"/> <label value="@load(('asdf' += 1234))"/>
Avoid calling methods by implementing dedicated bean getters:
<label value="@init(vm.buildFullName(person))"/> <!-- can be replaced by --> <label value="@init(person.fullName)"/>
and implement a getFullName method on the bean class