FileDocCategorySizeDatePackage
InputTransferSelect.javaAPI DocExample10860Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

InputTransferSelect

public class InputTransferSelect extends ListUIBean
Create a input transfer select component which is basically an text input and <select ...> tag with buttons in the middle of them allowing text to be added to the transfer select. Will auto-select all its elements upon its containing form submision.

NOTE: The id and doubleId need not be supplied as they will generated provided that the inputtransferselect tag is being used in a form tag. The generated id and doubleId will be <form_id>_<inputtransferselect_doubleName> and <form_id>_<inputtransferselect_doubleName> respectively.



<-- minimum configuration -->
<s:inputtransferselect
label="Favourite Cartoons Characters"
name="cartoons"
list="{'Popeye', 'He-Man', 'Spiderman'}"
/>


Fields Summary
private static final Log
_log
private static final String
TEMPLATE
protected String
size
protected String
multiple
protected String
allowRemoveAll
protected String
allowUpDown
protected String
leftTitle
protected String
rightTitle
protected String
buttonCssClass
protected String
buttonCssStyle
protected String
addLabel
protected String
removeLabel
protected String
removeAllLabel
protected String
upLabel
protected String
downLabel
protected String
headerKey
protected String
headerValue
Constructors Summary
public InputTransferSelect(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)



           
        super(stack, request, response);
    
Methods Summary
public voidevaluateExtraParams()

        super.evaluateExtraParams();

        if (size == null || size.trim().length() <= 0) {
            addParameter("size", "5");
        }

        if (multiple == null || multiple.trim().length() <= 0) {
            addParameter("multiple", Boolean.TRUE);
        }

        // allowUpDown
        addParameter("allowUpDown", allowUpDown != null ? findValue(allowUpDown, Boolean.class) : Boolean.TRUE);

        // allowRemoveAll
        addParameter("allowRemoveAll", allowRemoveAll != null ? findValue(allowRemoveAll, Boolean.class) : Boolean.TRUE);


        // leftTitle
        if (leftTitle != null) {
            addParameter("leftTitle", findValue(leftTitle, String.class));
        }

        // rightTitle
        if (rightTitle != null) {
            addParameter("rightTitle", findValue(rightTitle, String.class));
        }


        // buttonCssClass
        if (buttonCssClass != null && buttonCssClass.trim().length() > 0) {
            addParameter("buttonCssClass", buttonCssClass);
        }

        // buttonCssStyle
        if (buttonCssStyle != null && buttonCssStyle.trim().length() > 0) {
            addParameter("buttonCssStyle", buttonCssStyle);
        }

        // addLabel
        addParameter("addLabel", addLabel != null ? findValue(addLabel, String.class) : "->" );

        // removeLabel
        addParameter("removeLabel", removeLabel != null ? findValue(removeLabel, String.class) : "<-");

        // removeAllLabel
        addParameter("removeAllLabel", removeAllLabel != null ? findValue(removeAllLabel, String.class) : "<<--");


        // upLabel
        addParameter("upLabel", upLabel != null ? findValue(upLabel, String.class) : "^");


        // leftDownLabel
        addParameter("downLabel", downLabel != null ? findValue(downLabel, String.class) : "v");

        if ((headerKey != null) && (headerValue != null)) {
            addParameter("headerKey", findString(headerKey));
            addParameter("headerValue", findString(headerValue));
        }



        // inform the form component our select tag infos, so they know how to select
        // its elements upon onsubmit
        Form formAncestor = (Form) findAncestor(Form.class);
        if (formAncestor != null) {

            // inform ancestor form that we are having a customOnsubmit (see form-close.ftl [simple theme])
            enableAncestorFormCustomOnsubmit();


            // key -> select tag id, value -> headerKey (if exists)
            Map formInputtransferselectIds = (Map) formAncestor.getParameters().get("inputtransferselectIds");

            // init lists
            if (formInputtransferselectIds == null) {
                formInputtransferselectIds = new LinkedHashMap();
            }

            // id
            String tmpId = (String) getParameters().get("id");
            String tmpHeaderKey = (String) getParameters().get("headerKey");
            if (tmpId != null && (! formInputtransferselectIds.containsKey(tmpId))) {
                formInputtransferselectIds.put(tmpId, tmpHeaderKey);
            }

            formAncestor.getParameters().put("inputtransferselectIds", formInputtransferselectIds);

        }
        else {
            _log.warn("form enclosing inputtransferselect "+this+" not found, auto select upon form submit of inputtransferselect will not work");
        }
    
public java.lang.StringgetAddLabel()

        return addLabel;
    
public java.lang.StringgetAllowRemoveAll()

        return allowRemoveAll;
    
public java.lang.StringgetAllowUpDown()

        return allowUpDown;
    
public java.lang.StringgetButtonCssClass()

        return buttonCssClass;
    
public java.lang.StringgetButtonCssStyle()

        return buttonCssStyle;
    
protected java.lang.StringgetDefaultTemplate()

        return TEMPLATE;
    
public java.lang.StringgetDownLabel()

        return downLabel;
    
public java.lang.StringgetHeaderKey()

        return headerKey;
    
public java.lang.StringgetHeaderValue()

        return headerValue;
    
public java.lang.StringgetLeftTitle()

        return leftTitle;
    
public java.lang.StringgetMultiple()

        return multiple;
    
public java.lang.StringgetRemoveAllLabel()

        return removeAllLabel;
    
public java.lang.StringgetRemoveLabel()

        return removeLabel;
    
public java.lang.StringgetRightTitle()

        return rightTitle;
    
public java.lang.StringgetSize()

        return size;
    
public java.lang.StringgetUpLabel()

        return upLabel;
    
public voidsetAddLabel(java.lang.String addLabel)

        this.addLabel = addLabel;
    
public voidsetAllowRemoveAll(java.lang.String allowRemoveAll)

        this.allowRemoveAll = allowRemoveAll;
    
public voidsetAllowUpDown(java.lang.String allowUpDown)

        this.allowUpDown = allowUpDown;
    
public voidsetButtonCssClass(java.lang.String buttonCssClass)

        this.buttonCssClass = buttonCssClass;
    
public voidsetButtonCssStyle(java.lang.String buttonCssStyle)

        this.buttonCssStyle = buttonCssStyle;
    
public voidsetDownLabel(java.lang.String downLabel)

        this.downLabel = downLabel;
    
public voidsetHeaderKey(java.lang.String headerKey)

        this.headerKey = headerKey;
    
public voidsetHeaderValue(java.lang.String headerValue)

        this.headerValue = headerValue;
    
public voidsetLeftTitle(java.lang.String leftTitle)

        this.leftTitle = leftTitle;
    
public voidsetMultiple(java.lang.String multiple)

        this.multiple = multiple;
    
public voidsetRemoveAllLabel(java.lang.String removeAllLabel)

        this.removeAllLabel = removeAllLabel;
    
public voidsetRemoveLabel(java.lang.String removeLabel)

        this.removeLabel = removeLabel;
    
public voidsetRightTitle(java.lang.String rightTitle)

        this.rightTitle = rightTitle;
    
public voidsetSize(java.lang.String size)

        this.size = size;
    
public voidsetUpLabel(java.lang.String upLabel)

        this.upLabel = upLabel;