-
Bug
-
Resolution: Fixed
-
Normal
-
8.0.3
-
Security Level: Jimmy
-
None
-
None
Steps to Reproduce
run the example
right-click the buttons to show context menus
Actual Result
the button labeled "EL context id WRONG usage" does not show up a context menu
other buttons work
Expected Result
if a component is used incorrectly the user should get an error message or coerce the context/popup/tooltip ID to a string if not an instance of Popup
Debug Info
in this example the ID for the context menu is created from an integer variable
While the menupopup receives the correct ID (int is coerced to string) the context attribute of the button ignores the integer value without converting or showing an error message
Root Cause
side effect of the implementation for since ZK-3044
https://github.com/zkoss/zk/commit/20a7ac1c16ebacb58e163f71a5d41ed499487b78#diff-f7e7e86e183d469645504277a38176d5R356
The implementation correctly handles the types String and Popup but ignores anything else without warning or error message.
On the other hand when setting the menupopup ID using the same EL it the conversion to String happens automatically.
So instead of producing a warning the implementation could also do something like this:
_properties.put("context", new ObjectPropertyAccess() { public void setValue(Component cmp, Object context) { if (context instanceof Popup) ((XulElement) cmp).setContext((Popup) context); else ((XulElement) cmp).setContext(String.valueOf(context)); //maybe requires a null-check too } public String getValue(Component cmp) { return ((XulElement) cmp).getContext(); } });
Workaround
convert the value to a String manually
e.g. by string concatenation:
<button context="${('' += contextId)}"/>
- relates to
-
ZK-3044 ZK 8 popup/context/tooltip binding via EL/ZK-Bind
- Closed