FileDocCategorySizeDatePackage
OptGroup.javaAPI DocExample5021Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

OptGroup

public class OptGroup extends Component
Create a optgroup component which needs to resides within a select tag.

This component is to be used within a Select component.



<s:select label="My Selection"
name="mySelection"
value="%{'POPEYE'}"
list="%{#{'SUPERMAN':'Superman', 'SPIDERMAN':'spiderman'}}">
<s:optgroup label="Adult"
list="%{#{'SOUTH_PARK':'South Park'}}" />
<s:optgroup label="Japanese"
list="%{#{'POKEMON':'pokemon','DIGIMON':'digimon','SAILORMOON':'Sailormoon'}}" />
</s:select>


Fields Summary
public static final String
INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY
private static Log
_log
protected HttpServletRequest
req
protected HttpServletResponse
res
protected ListUIBean
internalUiBean
Constructors Summary
public OptGroup(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest req, HttpServletResponse res)


           
        super(stack);
        this.req = req;
        this.res = res;
        internalUiBean = new ListUIBean(stack, req, res) {
            protected String getDefaultTemplate() {
                return "empty";
            }
        };
    
Methods Summary
public booleanend(java.io.Writer writer, java.lang.String body)

        Select select = (Select) findAncestor(Select.class);
        if (select == null) {
            _log.error("incorrect use of OptGroup component, this component must be used within a Select component",
                    new IllegalStateException("incorrect use of OptGroup component, this component must be used within a Select component"));
            return false;
        }
        internalUiBean.start(writer);
        internalUiBean.end(writer, body);

        List listUiBeans = (List) select.getParameters().get(INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY);
        if (listUiBeans == null) {
            listUiBeans = new ArrayList();
        }
        listUiBeans.add(internalUiBean);
        select.addParameter(INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY, listUiBeans);

        return false;
    
public voidsetContainer(com.opensymphony.xwork2.inject.Container container)

        container.inject(internalUiBean);
    
public voidsetDisabled(java.lang.String disabled)

        internalUiBean.setDisabled(disabled);
    
public voidsetLabel(java.lang.String label)

        internalUiBean.setLabel(label);
    
public voidsetList(java.lang.String list)

        internalUiBean.setList(list);
    
public voidsetListKey(java.lang.String listKey)

        internalUiBean.setListKey(listKey);
    
public voidsetListValue(java.lang.String listValue)

        internalUiBean.setListValue(listValue);