1. leonate NA
  2. jxls
  3. Issues


Issue #82 resolved

xl:each - if you declare a var with the same name as a var already in the Context, previous var is removed from the context after processing the each command

nicolas frank
created an issue

I don't think this is an intentional behaviour, just that you didn't meet this specific case : I can see in the code,that the var declartion is added to the Context (through putVar, in EachCommand.java : for (Object obj : itemsCollection) { context.putVar(varName, obj); ). The at the end of the each it is removed Context (EachCommand.java line 289 --> context.removeVar(varName);).

So one simple solution could be to check if the var name is already present in Context befor the for loop. If so keep a local reference on this object and restore it after the for loop :

Object currentVarNameObject = null; if (context.getVar(varName)!=null) { currentVarNameObject=context.getVar(varName); } for ... { ... }

if (currentVarNameObject!=null) { context.putVar(varName, currentVarNameObject); }