FileDocCategorySizeDatePackage
UpDownSelect.javaAPI DocExample7542Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

UpDownSelect

public class UpDownSelect extends Select
Create a Select component with buttons to move the elements in the select component up and down. When the containing form is submited, its elements will be submitted in the order they are arranged (top to bottom).



<!-- Example 1: simple example -->
<s:updownselect
list="#{'england':'England', 'america':'America', 'germany':'Germany'}"
name="prioritisedFavouriteCountries"
headerKey="-1"
headerValue="--- Please Order Them Accordingly ---"
emptyOption="true" />

<!-- Example 2: more complex example -->
<s:updownselect
list="defaultFavouriteCartoonCharacters"
name="prioritisedFavouriteCartoonCharacters"
headerKey="-1"
headerValue="--- Please Order ---"
emptyOption="true"
allowMoveUp="true"
allowMoveDown="true"
allowSelectAll="true"
moveUpLabel="Move Up"
moveDownLabel="Move Down"
selectAllLabel="Select All" />


version
$Date: 2007-01-18 19:21:57 -0500 (Thu, 18 Jan 2007) $ $Id: UpDownSelect.java 497654 2007-01-19 00:21:57Z rgielen $
s.tag
name="updownselect" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.UpDownSelectTag" description="Render a up down select element"

Fields Summary
private static final Log
_log
public static final String
TEMPLATE
protected String
allowMoveUp
protected String
allowMoveDown
protected String
allowSelectAll
protected String
moveUpLabel
protected String
moveDownLabel
protected String
selectAllLabel
Constructors Summary
public UpDownSelect(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)

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

        super.evaluateParams();


        // override Select's default
        if (size == null || size.trim().length() <= 0) {
            addParameter("size", "5");
        }
        if (multiple == null || multiple.trim().length() <= 0) {
            addParameter("multiple", Boolean.TRUE);
        }



        if (allowMoveUp != null) {
            addParameter("allowMoveUp", findValue(allowMoveUp, Boolean.class));
        }
        if (allowMoveDown != null) {
            addParameter("allowMoveDown", findValue(allowMoveDown, Boolean.class));
        }
        if (allowSelectAll != null) {
            addParameter("allowSelectAll", findValue(allowSelectAll, Boolean.class));
        }

        if (moveUpLabel != null) {
            addParameter("moveUpLabel", findString(moveUpLabel));
        }
        if (moveDownLabel != null) {
            addParameter("moveDownLabel", findString(moveDownLabel));
        }
        if (selectAllLabel != null) {
            addParameter("selectAllLabel", findString(selectAllLabel));
        }


        // inform our form ancestor about this UpDownSelect so the form knows how to
        // auto select all options upon it submission
        Form ancestorForm = (Form) findAncestor(Form.class);
        if (ancestorForm != null) {

            // inform form ancestor that we are using a custom onsubmit
            enableAncestorFormCustomOnsubmit();

            Map m = (Map) ancestorForm.getParameters().get("updownselectIds");
            if (m == null) {
                // map with key -> id ,  value -> headerKey
                m = new LinkedHashMap();
            }
            m.put(getParameters().get("id"), getParameters().get("headerKey"));
            ancestorForm.getParameters().put("updownselectIds", m);
        }
        else {
            _log.warn("no ancestor form found for updownselect "+this+", therefore autoselect of all elements upon form submission will not work ");
        }
    
public java.lang.StringgetAllowMoveDown()

        return allowMoveDown;
    
public java.lang.StringgetAllowMoveUp()

        return allowMoveUp;
    
public java.lang.StringgetAllowSelectAll()

        return allowSelectAll;
    
public java.lang.StringgetDefaultTemplate()



       
        return TEMPLATE;
    
public java.lang.StringgetMoveDownLabel()

        return moveDownLabel;
    
public java.lang.StringgetMoveUpLabel()

        return moveUpLabel;
    
public java.lang.StringgetSelectAllLabel()

        return selectAllLabel;
    
public voidsetAllowMoveDown(java.lang.String allowMoveDown)

        this.allowMoveDown = allowMoveDown;
    
public voidsetAllowMoveUp(java.lang.String allowMoveUp)

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

        this.allowSelectAll = allowSelectAll;
    
public voidsetMoveDownLabel(java.lang.String moveDownLabel)

        this.moveDownLabel = moveDownLabel;
    
public voidsetMoveUpLabel(java.lang.String moveUpLabel)

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

        this.selectAllLabel = selectAllLabel;