FileDocCategorySizeDatePackage
BuildCheckboxTag.javaAPI DocExample1934Tue Feb 28 11:34:06 GMT 2006com.ora.jsp.tags.xmp

BuildCheckboxTag

public class BuildCheckboxTag extends TagSupport
This class is a custom action for creating an HTML checkbox control, using status information exposed by the JSTL forEach action.
author
Hans Bergsten, Gefion software
version
2.0

Fields Summary
private String
name
private String[]
selections
Constructors Summary
Methods Summary
public intdoEndTag()

        LoopTag parent = (LoopTag) findAncestorWithClass(this, LoopTag.class);
        if (parent == null) {
            throw new JspTagException("buildCheckbox: invalid parent");
        }

        Map.Entry current = (Map.Entry) parent.getCurrent();
        String text = (String) current.getKey();
        String value = (String) current.getValue();
        JspWriter out = pageContext.getOut();
        StringBuffer checkbox = new StringBuffer("<input type=\"checkbox\"");
        checkbox.append(" name=\"").append(name).append("\"").
            append(" value=\"").append(value).append("\"");
        if (isSelected(value, selections)) {
            checkbox.append(" checked");
        }
        checkbox.append(">").append(text);
        try {
            out.write(checkbox.toString());
        }
        catch (IOException e) {}
        return EVAL_PAGE;
    
private booleanisSelected(java.lang.String value, java.lang.String[] selections)

        return StringFormat.isValidString(value, selections, false); 
    
public voidsetName(java.lang.String name)

        this.name = name;
    
public voidsetSelections(java.lang.String[] selections)

        this.selections = selections;