FileDocCategorySizeDatePackage
OptionTransferSelect.javaAPI DocExample20247Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

OptionTransferSelect

public class OptionTransferSelect extends DoubleListUIBean
Create a option transfer select component which is basically two <select ...> tag with buttons in the middle of them allowing options in each of the <select ...> to be moved between themselves. 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 optiontransferselect tag is being used in a form tag. The generated id and doubleId will be <form_id>_<optiontransferselect_doubleName> and <form_id>_<optiontransferselect_doubleName> respectively.



<-- minimum configuration -->
<s:optiontransferselect
label="Favourite Cartoons Characters"
name="leftSideCartoonCharacters"
list="{'Popeye', 'He-Man', 'Spiderman'}"
doubleName="rightSideCartoonCharacters"
doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
/>

<-- possible configuration -->
<s:optiontransferselect
label="Favourite Cartoons Characters"
name="leftSideCartoonCharacters"
leftTitle="Left Title"
rightTitle="Right Title"
list="{'Popeye', 'He-Man', 'Spiderman'}"
multiple="true"
headerKey="headerKey"
headerValue="--- Please Select ---"
emptyOption="true"
doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
doubleName="rightSideCartoonCharacters"
doubleHeaderKey="doubleHeaderKey"
doubleHeaderValue="--- Please Select ---"
doubleEmptyOption="true"
doubleMultiple="true"
/>


Fields Summary
private static final Log
_log
private static final String
TEMPLATE
protected String
allowAddToLeft
protected String
allowAddToRight
protected String
allowAddAllToLeft
protected String
allowAddAllToRight
protected String
allowSelectAll
protected String
allowUpDownOnLeft
protected String
allowUpDownOnRight
protected String
leftTitle
protected String
rightTitle
protected String
buttonCssClass
protected String
buttonCssStyle
protected String
addToLeftLabel
protected String
addToRightLabel
protected String
addAllToLeftLabel
protected String
addAllToRightLabel
protected String
selectAllLabel
protected String
leftUpLabel
protected String
leftDownlabel
protected String
rightUpLabel
protected String
rightDownLabel
protected String
addToLeftOnclick
protected String
addToRightOnclick
protected String
addAllToLeftOnclick
protected String
addAllToRightOnclick
protected String
selectAllOnclick
protected String
upDownOnLeftOnclick
protected String
upDownOnRightOnclick
Constructors Summary
public OptionTransferSelect(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)



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

        super.evaluateExtraParams();

        Object doubleValue = null;

        // override DoubleListUIBean's
        if (doubleList != null) {
            doubleValue = findValue(doubleList);
            addParameter("doubleList", doubleValue);
        }
        if (size == null || size.trim().length() <= 0) {
            addParameter("size", "15");
        }
        if (doubleSize == null || doubleSize.trim().length() <= 0) {
            addParameter("doubleSize", "15");
        }
        if (multiple == null || multiple.trim().length() <= 0) {
            addParameter("multiple", Boolean.TRUE);
        }
        if (doubleMultiple == null || doubleMultiple.trim().length() <= 0) {
            addParameter("doubleMultiple", Boolean.TRUE);
        }





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

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



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

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

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

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

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

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

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


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

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


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

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

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

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

        // selectAllLabel
        addParameter("selectAllLabel",
                selectAllLabel != null ? findValue(selectAllLabel, String.class) : "<*>");

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


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


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


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


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

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

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

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

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

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

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


        // 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 formOptiontransferselectIds = (Map) formAncestor.getParameters().get("optiontransferselectIds");
            Map formOptiontransferselectDoubleIds = (Map) formAncestor.getParameters().get("optiontransferselectDoubleIds");

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


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

            // doubleId
            String tmpDoubleId = (String) getParameters().get("doubleId");
            String tmpDoubleHeaderKey = (String) getParameters().get("doubleHeaderKey");
            if (tmpDoubleId != null && (! formOptiontransferselectDoubleIds.containsKey(tmpDoubleId))) {
                formOptiontransferselectDoubleIds.put(tmpDoubleId, tmpDoubleHeaderKey);
            }

            formAncestor.getParameters().put("optiontransferselectIds", formOptiontransferselectIds);
            formAncestor.getParameters().put("optiontransferselectDoubleIds", formOptiontransferselectDoubleIds);

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

        return addAllToLeftLabel;
    
public java.lang.StringgetAddAllToLeftOnclick()

        return addAllToLeftOnclick;
    
public java.lang.StringgetAddAllToRightLabel()

        return addAllToRightLabel;
    
public java.lang.StringgetAddAllToRightOnclick()

        return addAllToRightOnclick;
    
public java.lang.StringgetAddToLeftLabel()

        return addToLeftLabel;
    
public java.lang.StringgetAddToLeftOnclick()

        return addToLeftOnclick;
    
public java.lang.StringgetAddToRightLabel()

        return addToRightLabel;
    
public java.lang.StringgetAddToRightOnclick()

        return addToRightOnclick;
    
public java.lang.StringgetAllowAddAllToLeft()

        return allowAddAllToLeft;
    
public java.lang.StringgetAllowAddAllToRight()

        return allowAddAllToRight;
    
public java.lang.StringgetAllowAddToLeft()

        return allowAddToLeft;
    
public java.lang.StringgetAllowAddToRight()

        return allowAddToRight;
    
public java.lang.StringgetAllowSelectAll()

        return this.allowSelectAll;
    
public java.lang.StringgetAllowUpDownOnLeft()

        return this.allowUpDownOnLeft;
    
public java.lang.StringgetAllowUpDownOnRight()

        return this.allowUpDownOnRight;
    
public java.lang.StringgetButtonCssClass()

        return buttonCssClass;
    
public java.lang.StringgetButtonCssStyle()

        return this.buttonCssStyle;
    
protected java.lang.StringgetDefaultTemplate()

        return TEMPLATE;
    
public java.lang.StringgetLeftDownLabel()

        return this.leftDownlabel;
    
public java.lang.StringgetLeftTitle()

        return leftTitle;
    
public java.lang.StringgetLeftUpLabel()

        return this.leftUpLabel;
    
public java.lang.StringgetRightDownLabel()

        return rightDownLabel;
    
public java.lang.StringgetRightTitle()

        return rightTitle;
    
public java.lang.StringgetRightUpLabel()

        return this.rightUpLabel;
    
public java.lang.StringgetSelectAllLabel()

        return this.selectAllLabel;
    
public java.lang.StringgetSelectAllOnclick()

        return this.selectAllOnclick;
    
public java.lang.StringgetUpDownOnLeftOnclick()

        return this.upDownOnLeftOnclick;
    
public java.lang.StringgetUpDownOnRightOnclick()

        return this.upDownOnRightOnclick;
    
public voidsetAddAllToLeftLabel(java.lang.String addAllToLeftLabel)

        this.addAllToLeftLabel = addAllToLeftLabel;
    
public voidsetAddAllToLeftOnclick(java.lang.String addAllToLeftOnclick)

        this.addAllToLeftOnclick = addAllToLeftOnclick;
    
public voidsetAddAllToRightLabel(java.lang.String addAllToRightLabel)

        this.addAllToRightLabel = addAllToRightLabel;
    
public voidsetAddAllToRightOnclick(java.lang.String addAllToRightOnclick)

        this.addAllToRightOnclick = addAllToRightOnclick;
    
public voidsetAddToLeftLabel(java.lang.String addToLeftLabel)

        this.addToLeftLabel = addToLeftLabel;
    
public voidsetAddToLeftOnclick(java.lang.String addToLeftOnclick)

        this.addToLeftOnclick = addToLeftOnclick;
    
public voidsetAddToRightLabel(java.lang.String addToRightLabel)

        this.addToRightLabel = addToRightLabel;
    
public voidsetAddToRightOnclick(java.lang.String addToRightOnclick)

        this.addToRightOnclick = addToRightOnclick;
    
public voidsetAllowAddAllToLeft(java.lang.String allowAddAllToLeft)

        this.allowAddAllToLeft = allowAddAllToLeft;
    
public voidsetAllowAddAllToRight(java.lang.String allowAddAllToRight)

        this.allowAddAllToRight = allowAddAllToRight;
    
public voidsetAllowAddToLeft(java.lang.String allowAddToLeft)

        this.allowAddToLeft = allowAddToLeft;
    
public voidsetAllowAddToRight(java.lang.String allowAddToRight)

        this.allowAddToRight = allowAddToRight;
    
public voidsetAllowSelectAll(java.lang.String allowSelectAll)

        this.allowSelectAll = allowSelectAll;
    
public voidsetAllowUpDownOnLeft(java.lang.String allowUpDownOnLeft)

        this.allowUpDownOnLeft = allowUpDownOnLeft;
    
public voidsetAllowUpDownOnRight(java.lang.String allowUpDownOnRight)

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

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

        this.buttonCssStyle = buttonCssStyle;
    
public voidsetLeftDownLabel(java.lang.String leftDownLabel)

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

        this.leftTitle = leftTitle;
    
public voidsetLeftUpLabel(java.lang.String leftUpLabel)

        this.leftUpLabel = leftUpLabel;
    
public voidsetRightDownLabel(java.lang.String rightDownlabel)

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

        this.rightTitle = rightTitle;
    
public voidsetRightUpLabel(java.lang.String rightUpLabel)

        this.rightUpLabel = rightUpLabel;
    
public voidsetSelectAllLabel(java.lang.String selectAllLabel)

        this.selectAllLabel = selectAllLabel;
    
public voidsetSelectAllOnclick(java.lang.String selectAllOnclick)

        this.selectAllOnclick = selectAllOnclick;
    
public voidsetUpDownOnLeftOnclick(java.lang.String upDownOnLeftOnclick)

        this.upDownOnLeftOnclick = upDownOnLeftOnclick;
    
public voidsetUpDownOnRightOnclick(java.lang.String upDownOnRightOnclick)

        this.upDownOnRightOnclick = upDownOnRightOnclick;