ForEachOptionTagpublic 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
|
Fields Summary |
---|
private Map | options | private String[] | selections | private Iterator | iterator |
Methods Summary |
---|
protected boolean | hasNext()
if (iterator == null) {
return false;
}
else {
return iterator.hasNext();
}
| private boolean | isSelected(java.lang.String value)
return StringFormat.isValidString(value, selections, false);
| protected java.lang.Object | next()
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 void | prepare()
if (options != null) {
iterator = options.entrySet().iterator();
}
| public void | setOptions(java.util.Map options)
this.options = options;
| public void | setSelections(java.lang.String[] selections)
this.selections = selections;
|
|