0

i have created a simple webflow.

enter image description here

It has two steps. In the first step you must input the name of group and in the second one contact information. The contact is added to group when you click on add contact. By click then on save group the group must be saved. Practically it works, but i meet only one issue i can't understand. The instance of EmailGroupForm contains in the collection all ContactForm, but each ContactForm has empty fields.

here is the class diagram:

enter image description here

I have debugged at the method, where the ContactForm is added to EmailGroupForm. All ContactForm are initialized. I have noted, that in each method, there is different instance of ContactForm. I think it is the reason of issue, but i am not sure. I don't understand where is my thought error.

Please to help

The project tutorial.spring4-tiles-simple-webflow is in gihub

1 Answers1

0

I think the default spring webflow binder is having trouble mapping the form fields to complex map type Map after you click submit/save

Try changing

from:

public class OrderForm implements Serializable {

    private Map <Book, Integer> selectedBooks = new HashMap<Book, Integer>();

To:

    import org.springframework.util.AutoPopulatingList;

    public class OrderForm implements Serializable {

private AutoPopulatingList<Book> selectedBooks = new AutoPopulatingList<Book>(Book.class)

...

See this answer I wrote on a similar question for more details:

spring webflow submit array with new items

Community
  • 1
  • 1
Selwyn
  • 3,118
  • 1
  • 26
  • 33
  • Thank you for the answer. Unfortunately it doesn't work – student.cologne Mar 24 '16 at 19:25
  • 1
    @student upon further analysis this might be a variable scoping issue. Try changing 'flowScope.contactForm' -> 'viewScope.contactForm' I think and make sure you are init ContactForm everything you enter the view to add new contact. – Selwyn Mar 24 '16 at 20:25
  • YES, thank's for the idea! I did move the call `groupController.createNewContact()` from my `` to the next state ``. And now it works. – student.cologne Mar 25 '16 at 22:28