Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-415

Read cell values cause the error result

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 5.7.0
    • 5.5.0
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. run attached zul with related composer
      2. click the button to switch to another.zul
      you can see the cell value of C2
      3. click the button again to switch back
      4. check C2

      Current Result

      #ERROR!

      In server console log:

      SEVERE: null when eval CHAIN("A","B","C","D")
      java.lang.NullPointerException
      	at io.keikai.ui.impl.ComponentEvaluationContributor$1.resolveFunction(ComponentEvaluationContributor.java:68)
      	at io.keikai.model.impl.sys.formula.JoinFunctionMapper.resolveFunction(JoinFunctionMapper.java:60)
      	at io.keikaiex.formula.ELEvalFunction.hasFunction(ELEvalFunction.java:61)
      	at io.keikaiex.formula.ZKUDFFinder.findFunction(ZKUDFFinder.java:83)
      	at org.zkoss.poi.ss.formula.udf.AggregatingUDFFinder.findFunction(AggregatingUDFFinder.java:50)
      	at org.zkoss.poi.xssf.model.IndexedUDFFinder.findFunction(IndexedUDFFinder.java:41)
      	at org.zkoss.poi.ss.formula.WorkbookEvaluator.findUserDefinedFunction(WorkbookEvaluator.java:980)
      	at org.zkoss.poi.ss.formula.OperationEvaluationContext.findUserDefinedFunction(OperationEvaluationContext.java:342)
      	at org.zkoss.poi.ss.formula.UserDefinedFunction.evaluate(UserDefinedFunction.java:58)
      	at org.zkoss.poi.ss.formula.OperationEvaluatorFactory.evaluate(OperationEvaluatorFactory.java:152)
      	at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:625)
      	at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:355)
      	at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:294)
      	at io.keikai.model.impl.sys.formula.FormulaEngineImpl.evaluateFormula(FormulaEngineImpl.java:587)
      	at io.keikai.model.impl.sys.formula.FormulaEngineImpl.evaluate(FormulaEngineImpl.java:467)
      	at io.keikai.model.impl.CellImpl.evalFormula(CellImpl.java:201)
      	at io.keikai.model.impl.CellImpl.getFormulaResultType(CellImpl.java:218)
      	at io.keikai.ui.SpreadsheetCtrlImpl.getCellAttr(SpreadsheetCtrlImpl.java:495)
      	at io.keikai.ui.SpreadsheetCtrlImpl.getRangeAttrs(SpreadsheetCtrlImpl.java:382)
      	at io.keikai.ui.Spreadsheet.createActiveRange(Spreadsheet.java:1962)
      	at io.keikai.ui.Spreadsheet.renderProperties(Spreadsheet.java:1915)
      	at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2175)
      	at org.zkoss.zk.ui.AbstractComponent.redrawChildren(AbstractComponent.java:2266)
      	at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2207)
      	at org.zkoss.zk.ui.impl.UiVisualizer.redraw(UiVisualizer.java:1016)
      	at org.zkoss.zk.ui.impl.UiVisualizer.getResponses(UiVisualizer.java:710)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.getResponses(UiEngineImpl.java:1575)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1345)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611)
      

      Expected Result

      ABCD

      Workaround

      apply attached BookCleaner

      Root Cause

      When spreadsheet is detached, its Book's ComponentEvaluationContributor is not set to null. When evaluating a custom formula, it causes ComponentEvaluationContributor's comp to be null and cannot return the correct custom function. When re-assign the same Book object back to a Spreadsheet. Book's ComponentEvaluationContributor is not reset to a new one because it's not null. So the spreadsheet cannot evaluate a custom function correctly.

      Proposed solution

      Spreadsheet.java

      
          public void onPageDetached(Page page){
      ...
      		if(_bookCleaner!=null){
      			_bookCleaner.cleanup(desktop);  
          }
      

        1. another.zul
          0.4 kB
        2. BookCleaner.java
          1 kB
        3. customFunction2.xlsx
          10 kB
        4. keikai-415.zul
          0.6 kB
        5. Keikai415Composer.java
          1 kB
        6. MyCustomFunctions.java
          3 kB
        7. spreadsheet.zul
          0.4 kB

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

              Created:
              Updated:
              Resolved: