protected void useVariableForCustomExpression(JRDesignGroup group,
			JRDesignExpression jrExpression, CustomExpression customExpression)
			throws JRException {
		//1) Register CustomExpression object as a parameter
		String expToGroupByName = group.getName() + "_custom_expression";
		registerCustomExpressionParameter(expToGroupByName, customExpression);
		
		//2) Create a variable which is calculated through the custom expression
		JRDesignVariable gvar = new JRDesignVariable();
		String varName = group.getName() + "_variable_for_group_expression";
		gvar.setName(varName);
		gvar.setCalculation( CalculationEnum.NOTHING );
		gvar.setValueClassName(customExpression.getClassName());
		
		String expText = ExpressionUtils.createCustomExpressionInvocationText(customExpression, expToGroupByName, false);
		JRDesignExpression gvarExp = new JRDesignExpression();
		gvarExp.setValueClassName(customExpression.getClassName());
		gvarExp.setText(expText);
		gvar.setExpression(gvarExp);
		getDjd().addVariable(gvar);
		
		//3) Make the group expression point to the variable
		jrExpression.setText("$V{"+varName+"}");
		jrExpression.setValueClassName(customExpression.getClassName());
		log.debug("Expression for CustomExpression usgin variable = \"" + varName + "\" which point to: " + expText);
	}
protected void useVariableForCustomExpression ( JRDesignGroup group , JRDesignExpression jrExpression , CustomExpression customExpression ) throws JRException { String expToGroupByName = group . getName ( ) + "_custom_expression" ; registerCustomExpressionParameter ( expToGroupByName , customExpression ) ; JRDesignVariable gvar = new JRDesignVariable ( ) ; String varName = group . getName ( ) + "_variable_for_group_expression" ; gvar . setName ( varName ) ; gvar . setCalculation ( CalculationEnum . NOTHING ) ; gvar . setValueClassName ( customExpression . getClassName ( ) ) ; String expText = ExpressionUtils . createCustomExpressionInvocationText ( customExpression , expToGroupByName , false ) ; JRDesignExpression gvarExp = new JRDesignExpression ( ) ; gvarExp . setValueClassName ( customExpression . getClassName ( ) ) ; gvarExp . setText ( expText ) ; gvar . setExpression ( gvarExp ) ; getDjd ( ) . addVariable ( gvar ) ; jrExpression . setText ( "$V{" + varName + "}" ) ; jrExpression . setValueClassName ( customExpression . getClassName ( ) ) ; log . debug ( "Expression for CustomExpression usgin variable = \"" + varName + "\" which point to: " + expText ) ; }
When a group expression gets its value from a CustomExpression, a variable must be used otherwise it will fail
to work as expected.<br><br>

Instead of using: GROUP -> CUSTOM_EXPRESSION<br>
<br>
we use: GROUP -> VARIABLE -> CUSTOM_EXPRESSION<br>
<br><br>
See http://jasperforge.org/plugins/mantis/view.php?id=4226 for more detail

@param group
@param jrExpression
@param customExpression
@throws JRException