-
Bug
-
Resolution: Fixed
-
Normal
-
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); }