Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bamboo Freemarker/Webworks multiple select issue

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"
/]

1 answer

0 votes

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()"
/]

<div id="interfaceDiv">
[@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"
/]
</div>

<div id="frameworkDiv">
[@ww.select 
label="List of Bars"
       id="frameworkBarId"   
       name="frameworkBarName"
       list="barFrameworkList"
       listKey="id"
       listValue="name"
       multiple="true"
       size="10"
       required="true"
/]
</div>

<script>
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";
  }
}
</script>

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<Deploy> deployTypeList = ImmutableList.of(
            new Deploy("1", "Framework"),
            new Deploy("2", "Interface"),
            new Deploy("3", "Jake"),
            new Deploy("4", "Broker Hub")
    );
    private static final Map<String, Deploy> deployTypeMap = Maps.uniqueIndex(deployTypeList, new Function<Deploy, String>()
    {
        @Override
        public String apply(Deploy deploy)
        {
            return deploy.getId();
        }
    });

    private static final List<Country> 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<String, Country> countryMap = Maps.uniqueIndex(countryList, new Function<Country, String>()
    {
        @Override
        public String apply(Country country)
        {
            return country.getId();
        }
    });

    private static final List<Bar> 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<Bar> 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<String, String> generateTaskConfigMap(@NotNull final ActionParametersMap params, @Nullable final TaskDefinition previousTaskDefinition)
    {
        final Map<String, String> 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<String, Object> 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<String, Object> 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<String, Object> 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);
    }
}


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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

221 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you