0
votes

im using webflow plugin, i create at the start action state 2 variables in flow scope one as a map and the other one as a list, then i pick up values among states until state 3 i add does values to a map and finally add the map to a list, until here is fine, the problem is when i try to add a second item just when I add the second map to the list, all previous map are overwrites.

If i change does variables created in the start action from flow scope to session scope map are not overwrites.

any idea? i would like to use flow variables. thanks for your time

def controllerNameFlow = {
init {
  flow.items = [:]
  flow.itemsCollection = []
}
on("success").to "state1"
on("error").to "done"

state1 = {
  flow.item = "abc"
}
on("confirm").to "state2"

state2 = {
  flow.presentation = "a123"
}
on("confirm").to "state3"

state3 = {
  flow.items.put("item", flow.item)
  flow.items.put("presentation", flow.presentation)

  flow.itemsCollection.add flow.items
}
on("confirm").to "state1"
}
1

1 Answers

0
votes

Lists can hold duplicate items, if you want the collection to not contain duplicate items then you should use a Set instead of a List

Chage

flow.itemsCollection = []

to

flow.itemsCollection = new HashSet()

Hope this helps