tags:

views:

510

answers:

1

I have a form where I have two fields that I can add as much as I can. Think of it as like the upload file in gmail where I can add 1,2,3... files to upload only that I have two fields.

I am not so sure how this will check out using a SimpleFormController in Spring. Will the Spring Controller bind the them automatically?

My command class looks like this:

public class Course {
    private long ID;
    private String Owner;
    private String Title;
    private String Learning Objective;

    //I am not so sure how this will be bound
    private List<LearningActivity> learningActivities;

    //accessor methods

}

public class LearningActivity {
   private String Description;
   private String link;

   //accessor methods 

}
+2  A: 

I would suggest you to use Annotation-based Spring controllers as SimpleFormController is deprecated as of spring 3.0

If you are using annotations based controller then their is no need to extend any class or implement any interface. The only thing you need to do to make your simple java class to become a Spring controller is to add the @Controller annotation to it.

Example here

Also for handling dynamic fields in the form, it is better that you use Spring Form Tags

Example here

Edit: check 5.4.2.1. Registering additional custom PropertyEditors in spring docs, it has an example of what u want

Narayan
rawr :( Unfortunately I am still using Spring 2.5.6. Is there a way to do this in Spring 2.5.6?
Jeune
see http://www.vaannila.com/spring/spring-simple-form-controller-1.html for example on simpleformcontroller
Narayan
Hi I saw the tutorial! It's great it answers some of my questions. There's one thing left though, I think I need I need to create a "custom property editor" because I have a custom data type (in my code above LearningActivity). Do you have any tutorials to do that? :)
Jeune
check my edited post
Narayan