Bamboo Freemarker/Webworks multiple select issue
Asked by edgarnmaistry:

I'm building a custom task with GUI in Bamboo using Atlassian SDK with Freemarker and Webworks. The single select works fine but multiple select does not return multiple values only single value. My FTL code looks like below. In my TaskConfigurator class the selectedBarList field is not returned only the interfaceBar paramter is retruned with single value.

@ww.select"\>\[@ww.selectlabel="List of Bars" id="interfaceBar" name="interfaceBar"  
list="barInterfaceList"  
listKey="id"  
listValue="name"  
value="selectedBarList"  
multiple="true"  
size="3"  
required="true"  
/\]


Answers:
author: Krystian Brazulewicz
body: If you explicitly specify "value" attribute then ww.select will not receive value from Freemarker context. Here's your code fixed:

```
[@ww.select label="Framework Deploy Or Interface Deploy"       id="deployType"          name="deployType"       list="deployTypeList"       listKey="id"       listValue="name"       multiple="false"       size="3"       required="true"       onclick="myFunction()"/]&lt;div id="interfaceDiv"&gt;[@ww.select label="Countries"       id="country"       name="country"       list="countryList"       listKey="id"       listValue="name"       multiple="false"       size="3"       required="true"       onclick="myFunction()"       /][@ww.select label="List of Bars"       id="interfaceBar"          name="interfaceBar"       list="barInterfaceList"       listKey="id"       listValue="name"       multiple="true"       size="3"       required="true"/]&lt;/div&gt;&lt;div id="frameworkDiv"&gt;[@ww.select label="List of Bars"       id="frameworkBarId"          name="frameworkBarName"       list="barFrameworkList"       listKey="id"       listValue="name"       multiple="true"       size="10"       required="true"/]&lt;/div&gt;&lt;script&gt;function myFunction(){  var deployType=document.getElementById("deployType");  alert("deploytype = " + deployType.value);    var interfaceDiv=document.getElementById("interfaceDiv");  var frameworkDiv=document.getElementById("frameworkDiv");  if (deployType.value=='1'){  	interfaceDiv.style.visibility="hidden";  	frameworkDiv.style.visibility="visible";  }  else{  	interfaceDiv.style.visibility="visible";  	frameworkDiv.style.visibility="hidden";  }}&lt;/script&gt;
```

```

```

```
and the Java part:
```

```
package helloworld1;import com.atlassian.bamboo.collections.ActionParametersMap;import com.atlassian.bamboo.task.AbstractTaskConfigurator;import com.atlassian.bamboo.task.TaskDefinition;import com.atlassian.bamboo.utils.error.ErrorCollection;import com.google.common.base.Function;import com.google.common.base.Joiner;import com.google.common.base.Objects;import com.google.common.base.Splitter;import com.google.common.collect.ImmutableList;import com.google.common.collect.Iterables;import com.google.common.collect.Maps;import com.opensymphony.xwork.TextProvider;import org.jetbrains.annotations.NotNull;import org.jetbrains.annotations.Nullable;import java.util.List;import java.util.Map;public class ExampleTaskConfigurator extends AbstractTaskConfigurator{    private TextProvider textProvider;    private static final String CFG_DEPLOY_TYPE = "deployType.id";    private static final String CFG_COUNTRY = "country.id";    private static final String CFG_INTERFACE = "interface.id";    private static final String CFG_FRAMEWORK = "framework.id";    private static final String UI_DEPLOY_TYPE = "deployType";    private static final String UI_DEPLOY_TYPE_NAME = "deployType.name";    private static final String UI_DEPLOY_TYPE_LIST = "deployTypeList";    private static final String UI_COUNTRY = "country";    private static final String UI_COUNTRY_NAME = "country.name";    private static final String UI_COUNTRY_LIST = "countryList";    private static final String UI_INTERFACE = "interfaceBar";    private static final String UI_INTERFACE_LIST = "barInterfaceList";    private static final String UI_FRAMEWORK = "frameworkBarName";    private static final String UI_FRAMEWORK_LIST = "barFrameworkList";    private static final List&lt;Deploy&gt; deployTypeList = ImmutableList.of(            new Deploy("1", "Framework"),            new Deploy("2", "Interface"),            new Deploy("3", "Jake"),            new Deploy("4", "Broker Hub")    );    private static final Map&lt;String, Deploy&gt; deployTypeMap = Maps.uniqueIndex(deployTypeList, new Function&lt;Deploy, String&gt;()    {        @Override        public String apply(Deploy deploy)        {            return deploy.getId();        }    });    private static final List&lt;Country&gt; countryList = ImmutableList.of(            new Country("1", "South Africa"),            new Country("2", "Tanzania"),            new Country("3", "Namibia"),            new Country("4", "Nigeria"),            new Country("5", "Uganda")    );    private static final Map&lt;String, Country&gt; countryMap = Maps.uniqueIndex(countryList, new Function&lt;Country, String&gt;()    {        @Override        public String apply(Country country)        {            return country.getId();        }    });    private static final List&lt;Bar&gt; barFrameworkList = ImmutableList.of(            new Bar("1", "Input"),            new Bar("2", "Output"),            new Bar("3", "Transformation"),            new Bar("4", "Fte"),            new Bar("5", "Logging")    );    private static final List&lt;Bar&gt; barInterfaceList = ImmutableList.of(            new Bar("1", "fin2pas"),            new Bar("2", "esb2esb"),            new Bar("3", "esb2mdm"),            new Bar("4", "sprw2abc"),            new Bar("5", "abc2xyz")    );    @NotNull    @Override    public Map&lt;String, String&gt; generateTaskConfigMap(@NotNull final ActionParametersMap params, @Nullable final TaskDefinition previousTaskDefinition)    {        final Map&lt;String, String&gt; config = super.generateTaskConfigMap(params, previousTaskDefinition);                config.put(CFG_DEPLOY_TYPE, params.getString(UI_DEPLOY_TYPE));        config.put(CFG_COUNTRY, params.getString(UI_COUNTRY));        // plugin developer is responsible for null-safe serializing all non-string properties into configuration map        config.put(CFG_INTERFACE, arrayToString(params.getStringArray(UI_INTERFACE)));        config.put(CFG_FRAMEWORK, arrayToString(params.getStringArray(UI_FRAMEWORK)));        System.out.println("config in generateTaskConfigMap: after put" + config);        return config;    }    @Override    public void populateContextForCreate(@NotNull final Map&lt;String, Object&gt; context)    {        super.populateContextForCreate(context);        context.put(UI_DEPLOY_TYPE_LIST, deployTypeList);        context.put(UI_COUNTRY_LIST, countryList);        context.put(UI_INTERFACE_LIST, barInterfaceList);        context.put(UI_FRAMEWORK_LIST, barFrameworkList);    }    @Override    public void populateContextForEdit(@NotNull final Map&lt;String, Object&gt; context, @NotNull final TaskDefinition taskDefinition)    {        super.populateContextForEdit(context, taskDefinition);        System.out.println("Edit: taskDefinition.getConfiguration() " + taskDefinition.getConfiguration());        // Populate the Lists        context.put(UI_DEPLOY_TYPE_LIST, deployTypeList);        context.put(UI_COUNTRY_LIST, countryList);        context.put(UI_INTERFACE_LIST, barInterfaceList);        context.put(UI_FRAMEWORK_LIST, barFrameworkList);        // Preselect chosen entry        context.put(UI_DEPLOY_TYPE, taskDefinition.getConfiguration().get(CFG_DEPLOY_TYPE));        context.put(UI_COUNTRY, taskDefinition.getConfiguration().get(CFG_COUNTRY));        // plugin developer is responsible for null-safe deserializing of all non-string properties from configuration map        context.put(UI_INTERFACE, stringToArray(taskDefinition.getConfiguration().get(CFG_INTERFACE)));        context.put(UI_FRAMEWORK, stringToArray(taskDefinition.getConfiguration().get(CFG_FRAMEWORK)));    }    @Override    public void populateContextForView(@NotNull final Map&lt;String, Object&gt; context, @NotNull final TaskDefinition taskDefinition)    {        super.populateContextForView(context, taskDefinition);        context.put(UI_DEPLOY_TYPE_NAME, deployTypeMap.get(taskDefinition.getConfiguration().get(CFG_DEPLOY_TYPE)));        context.put(UI_COUNTRY_NAME, countryMap.get(taskDefinition.getConfiguration().get(CFG_COUNTRY)));    }    @Override    public void validate(@NotNull final ActionParametersMap params, @NotNull final ErrorCollection errorCollection)    {        super.validate(params, errorCollection);//        final String sayValue = params.getString("say");//        if (StringUtils.isEmpty(sayValue))//        {//            errorCollection.addError("say", textProvider.getText("helloworld1.say.error"));//        }    }    public void setTextProvider(final TextProvider textProvider)    {        this.textProvider = textProvider;    }    @NotNull    private String arrayToString(@Nullable String[] input)    {        return Joiner.on(",").join(Objects.firstNonNull(input, new String[]{}));    }    @NotNull    private String[] stringToArray(@Nullable String input)    {        return Iterables.toArray(Splitter.on(",").split(Objects.firstNonNull(input, "")), String.class);    }}
```

```

```

comments: author: vbvaghela952
body: Can you help me with creation of a simple dropdown ?

What are the steps needed if I want to create a simple dropdown and get the selected value, persist it.

I cannot find any reference in documentation or anywhere.

Please, That would be much helpful.

Thanks.