/** * Return a parameter by its name. If the parameter is not defined, returns null * * @param name Parameter name to be used. * @return a parameter by its name. If the parameter is not defined, returns null. */ protected Object getParameter(String name) { return tag.getParam(name); }
/** * 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))); }
protected void setAttributeInterpreter(FormaterTagDynamicAttributesInterpreter interpreter) { tag.addProcessingInstruction( ProcessingInstruction.getAddAttributesInterpreterInstruction(interpreter)); }
protected void writeToOut(String text) { if (log.isDebugEnabled()) log.debug("Writting '" + text + "' to output, scheduled."); tag.addProcessingInstruction(ProcessingInstruction.getWriteToOutInstruction(text)); }
protected void includePage(String pageName) { if (log.isDebugEnabled()) log.debug("Including of page " + pageName + " scheduled."); tag.addProcessingInstruction(ProcessingInstruction.getIncludePageInstruction(pageName)); }
/** * Orders the processing of fragment with given name. * * @param fragmentName Name of the fragment to be rendered. */ protected void renderFragment(String fragmentName) { if (log.isDebugEnabled()) log.debug("Rendering of fragment " + fragmentName + " scheduled."); tag.addProcessingInstruction(ProcessingInstruction.getRenderFragmentInstruction(fragmentName)); }