Php5 web hosting - JavaSercer Pages Current value: Here, the tag iterates

JavaSercer Pages

    Current value: <%= x %>    

Here, the tag iterates over the elements of a String array, adding the current value to the response using a JSP expression in the action’s body. The com.ora.jsp.tags.generic.LoopTag class is the tag handler class for the action. It extends BodyTag support and has four properties: public class LoopTag extends BodyTagSupport { private String name; private String loopId; private String className; private String property; … A standard property setter method is provided for each property. This is no different than in previous examples, so it’s not shown here. The name, loopId, and className properties are mandatory. The name is the name of a JSP scope variable of one of the types listed earlier. The current value of the data structure is made available in the element body through a variable with the name specified by loopId, of the type specified by className. Optionally, property can be specified. If it is, it’s used to get the data structure from the specified property of the bean named by name, instead of using the name object itself as the data structure. To make the loopId variable available in the element’s body, a TagExtraInfo subclass is needed, as described in the previous section. The LoopTagExtraInfo class looks like this: public class LoopTagExtraInfo extends TagExtraInfo { public VariableInfo[] getVariableInfo(TagData data) { return new VariableInfo[] { new VariableInfo(data.getAttributeString(”loopId”), data.getAttributeString(”className”), true, VariableInfo.NESTED) }; } } It introduces a variable named by the loopId attribute, with the type specified by the className attribute. The scope is specified as NESTED, meaning the variable is available only within the action element’s body. In addition to the property variables, the tag handler class has an Enumeration instance variable: private Enumeration enum; This variable is initiated by the doStartTag( ) method: public int doStartTag( ) throws JspException { Object obj = pageContext.findAttribute(name); if (obj == null) { throw new JspException(”Variable ” + name + ” not found”); } Object mvObj = obj; try { // Get the multi-value object using the specified property // getter method, if any if (property != null) { mvObj = getProperty(obj, property); } enum = getEnumeration(mvObj); } catch (JspException e) { throw new JspException(”Error getting loop data from ” + name + “: ” + e.getMessage( )); } page 227

Hint: If you are looking for high quality and reliable webspace provider to host and run your jsp hosting application check Sandzak jsp web hosting provider

Comments are closed.