2 Replies Latest reply: Jun 6, 2012 9:19 AM by AliB RSS

    Problem when calculating Salary rows

    AliB
      Hello all,
      We use Jdeveloper 11.1.1.4.0 with JHS 11.1.1.4.26.

      I'm trying to calculate the Salary field from Employees table and then put the result in the table footer as follows:

      1- Building an Entity on Employees table
      2- Going to Salary field Attributes -> Control hints and then put the follwoing values:
      - Format type = number
      - Format = #,##0,00
      3- Building a new page from JHS and putting the following value on the Salary field:
      - Display Summary Type in table = sum

      When executing the application it throws an exception:
      java.lang.NumberFormatException: For input string: "

      When debugging the code, we find that the JHS Calls a method from TableBean.java named as sumRow.
      Inside this method, the input value cannot be converted from string to number

      Any suggestions will be appreciated.

      Thanks,
      Ali.
        • 1. Re: Problem when calculating Salary rows
          Steven Davelaar-Oracle
          Ali,

          This is a bug indeed. To fix it, you should crate a subclass of the Jheadstart table bean and override method getSumRow to return your own map

          public Map getSumRow()
          {
          return sumRowFixed;
          }

          And the private map class looks like this:


          private Map sumRowFixed= new HashMap()
          {
          public Object get(Object key)
          {
          Number total = new Number(0);
          int rowsWithValue = 0;
          int rowCount = getTable()!=null ? getTable().getRowCount() : 0;
          for (int i = 0; i < rowCount; i++)
          {
          Map rowData = (Map) getTable().getRowData(i);
          if (rowData != null)
          {
          Object objectValue = rowData.get(key);
          if (objectValue == null)
          {
          continue;
          }
          Number value = null;
          if (objectValue instanceof Number)
          {
          value = (Number) objectValue;
          }
          else if (rowData instanceof JUCtrlHierNodeBinding)
          {
          JUCtrlHierNodeBinding node = (JUCtrlHierNodeBinding)rowData;
          objectValue = node.getRow().getAttribute(key.toString());
          if (objectValue instanceof Number)
          {
          value = (Number) objectValue;
          }
          }
          if (value != null)
          {
          total = total.add(value);
          rowsWithValue++;
          }
          }
          }
          return total;
          }
          };

          Then change the tableBean.vm template to use your subclass.

          We will include the fix in the next release.

          Steven Davelaar,
          Jheadstart team.
          • 2. Re: Problem when calculating Salary rows
            AliB
            Hello Steven,

            your solution is working like a charm
            Thanks for your cooperation...I appreciate

            Best regards,
            Ali.