Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3554

Tooltip/Popup/Context ignoring usage errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.0
    • 8.0.3
    • Components
    • Security Level: Jimmy
    • 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)}"/>
      

            bobpeng bobpeng
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h