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

cannot call formatNumber(Object number, String pattern, Locale locale)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Normal Normal
    • 9.6.0
    • 9.5.1.3
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. run the zul

      Current Result

      org.zkoss.zel.ELException: Function 'c:formatNumber' specifies 2 params, but 3 were declared
      at org.zkoss.zel.impl.lang.ExpressionBuilder.visit(ExpressionBuilder.java:217)
      at org.zkoss.zel.impl.parser.SimpleNode.accept(SimpleNode.java:141)
      at org.zkoss.zel.impl.lang.ExpressionBuilder.prepare(ExpressionBuilder.java:150)
      at org.zkoss.zel.impl.lang.ExpressionBuilder.build(ExpressionBuilder.java:168)
      at org.zkoss.zel.impl.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:231)
      at org.zkoss.zel.impl.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:66)
      at org.zkoss.xel.zel.ELFactory.parseExpression(ELFactory.java:43)
      at org.zkoss.zk.xel.impl.SimpleEvaluator.parseExpression(SimpleEvaluator.java:61)
      at org.zkoss.zk.ui.metainfo.AbstractEvalRef.parseExpression(AbstractEvalRef.java:38)
      at org.zkoss.zk.xel.ExValue.init(ExValue.java:122)
      at org.zkoss.zk.xel.ExValue.getValue(ExValue.java:110)
      at org.zkoss.zk.ui.metainfo.Property.getValue(Property.java:138)
      at org.zkoss.zk.ui.metainfo.Property.assign0(Property.java:234)
      at org.zkoss.zk.ui.metainfo.Property.assign(Property.java:174)
      at org.zkoss.zk.ui.metainfo.ComponentInfo.applyProperties(ComponentInfo.java:742)
      at org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:150)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:921)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:891)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:778)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:838)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:796)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:742)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:463)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:371)
      at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:220)

      Expected Result

      format the number without the exception

      Debug Information

      1. according to https://www.zkoss.org/wiki/ZUML%20Reference/EL%20Expressions/Core%20Methods/formatNumber and ZK-1047, this function should be supported.
      2. the number of parameters in the error message is also wrong, it should be:
      Function 'c:formatNumber' specifies 3 params, but 2 were declared
      3. in zweb, core.dsp.tld only declares a 2 parameters of formatNumber()
      It once had the 3 parameters-function but was changed in 2012/4/27 commit, SHA 77c97109b37e12078ca7f339ad63ed4aba0372c9

      Workaround

      1. define a custom taglib
      in WEB-INF/tld/mytag.tld

      <taglib>
          <function>
              <name>formatNumber</name>
              <function-class>org.zkoss.xel.fn.CommonFns</function-class>
              <function-signature>java.lang.String formatNumber(java.lang.Object, java.lang.String, java.util.Locale)</function-signature>
              <description>
                  Returns the formatted number string.
              </description>
          </function>
      </taglib>
      

            DevChu DevChu
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: