/** * Sets a parameter for the fragment. The object set as parameter value must not be changed during * all the execution, otherwise the result won't be as expected. That is, if this object has a * method that changes its content, this method must not be called by the Formatter during the * service() method. Otherwise, all the rendering performed by the fragmentValue tag will use the * *last* version of the object, the one existing after the invocation of service method, which is * probably not expected. * * <p>Example, of a iterating formatter: <code> * StringBuffer sb = new StringBuffer();<br> * for( int i= 0; i<10; i++){<br> * sb.delete(0,sb.length())<br> * sb.append( i );<br> * setAttribute("index",sb);<br> * renderFragment("output");<br> * }<br> * * </code> will generate an output like : 10 10 10 10 10 10 10 10 10 10 while the expected output * is: 0 1 2 3 4 5 6 7 8 9 * * <p>So, use objects and don't change them. This is usually easy to accomplish, by using * different instances, in the example above, replace sb.delete(0,sb.length()) with sb = new * StringBuffer(); * * @param name Name of the parameter. * @param value It's value. Must not be changed during all the execution. */ protected void setAttribute(String name, double value) { if (log.isDebugEnabled()) log.debug("Setting of attribute " + name + " scheduled."); tag.addProcessingInstruction( ProcessingInstruction.getSetParameterInstruction(name, new Double(value))); }