Menu

Problem with multiForEach and multiple values in one cell

2014-05-01
2014-06-12
  • Mark Vejvoda

    Mark Vejvoda - 2014-05-01

    If i use a multiForEach with two lists of data. List1 has 3 rows and List2 has 0, I then try to do something like ${itemFromList1.name} : ${itemFromList2.name}

    The cell is always blank. I tried many ways to display both in one cell (expecting a blank value from ${itemFromList2.name} but see that the pastEndAction behavior will wipe out the cell no matter what i do. Is there some way to get past this?

     
  • Mark Vejvoda

    Mark Vejvoda - 2014-05-01

    I have a fix for this where in SheetUtil we now check if the cell has multiple expressions and if one of them is not pastend let the cell be processed (past end cell expressions will be empty). See Attached file (based on trunk sheetutil code)

     
  • Randy Gettman

    Randy Gettman - 2014-05-02

    I had thought of that possibility before, when I created PastEndAction. In the source code for that class I placed a comment indicating that I might need another value to indicate just the situation you have. But I never implemented that idea.

    Please file a ticket for tracking purposes. The patch you attached is interesting. Sometime, I will make a change to trigger the code you've written in a new case for PastEndAction - NULL_EXPR. Thanks!

     
  • Mark Vejvoda

    Mark Vejvoda - 2014-05-02

    Here is a better solution (need to pass in the vars list through the method chain):

    // This method patches original JETT past end processing so not clear a cell
    // if there is at least 1 expression tag that is not past end of its list
    private static boolean validatePastEndRefAction(Cell cell,
    List<String> pastEndRefs, boolean takeAction, List<String> myVarNames) {

      if(pastEndRefs != null && pastEndRefs.size() > 0) {
    
         // First we do oriignal legacy check to see if we should take an action
         // due to a variable being past end of its list
         String strValue = cell.getStringCellValue();
         for (String pastEndRef : pastEndRefs) {
             if (strValue != null && strValue.indexOf(pastEndRef) >= 0) {
                takeAction = true;
                break;
             }
         }
    
         // Since we are considering taking a past end action we will now do
         // a deeper look to see if we should really take an action but only
         // if all variables are past end of list used in the cell
         if(takeAction && myVarNames != null && myVarNames.size() > 0) {
            if (strValue != null) {
               boolean isExpressionPastEnd = true;
               for(String myVar : myVarNames) {
                  if (strValue.indexOf(myVar) >= 0) {
                     isExpressionPastEnd = false;
                     for (String pastEndRef : pastEndRefs) {
                        if (myVar.indexOf(pastEndRef) >= 0) {
                           isExpressionPastEnd = true;
                           break;
                        }
                     }
    
                     if(isExpressionPastEnd == false) {
                        takeAction = false;
                        break;
                     }
                  }
               }
            }
         }
      }
    
      return takeAction;
    

    }

     
  • Randy Gettman

    Randy Gettman - 2014-05-29

    FYI in JETT 0.7.0 I named the new past end action "replaceExpr". Any expression that contains a collection reference that has been exhausted already won't be evaluated; it will be replaced with the evaluation of the new attribute "replaceValue", which defaults to an empty string if not specified.

     
  • Mark Vejvoda

    Mark Vejvoda - 2014-06-12

    Thank you

     

Log in to post a comment.