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

ForEachOptionTag

public class ForEachOptionTag extends LoopTagSupport
This class is a custom action for creating HTML select lists, checkboxes or radio buttons, where some items need to be marked as selected based on dynamic data. The names and values for the options are provided through a Map, and the selected values are provided as a String[]. The action exposes a bean with three properties to actions in the body, representing the current Map entry:
  • String text
  • String value
  • boolean selected
author
Hans Bergsten, Gefion software
version
2.0

Fields Summary
private Map
options
private String[]
selections
private Iterator
iterator
Constructors Summary
Methods Summary
protected booleanhasNext()

        if (iterator == null) {
            return false;
        }
        else {
            return iterator.hasNext();
        }
    
private booleanisSelected(java.lang.String value)

        return StringFormat.isValidString(value, selections, false); 
    
protected java.lang.Objectnext()

        Map.Entry me = (Map.Entry) iterator.next();
        String text = (String) me.getKey();
        String value = (String) me.getValue();
        boolean selected = isSelected(value);
        return new OptionBean(text, value, selected);
    
protected voidprepare()

        if (options != null) {
            iterator = options.entrySet().iterator();
        }
    
public voidsetOptions(java.util.Map options)

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

        this.selections = selections;