Hi,

I solved this by overriding formBackingObject like so:

        protected Object formBackingObject(HttpServletRequest request)
                        throws Exception
        {
                log.debug("entering formBackingObject method");
                ToyProvider o = new ToyProvider();

                // Find out how many toys we have
                Enumeration enu = request.getParameterNames();
                int toysManufacturedCount = 0;
                while (enu.hasMoreElements())
                {
                        String paramName = (String) enu.nextElement();
                        log.debug("got request param: " + paramName);
                        if 
(paramName.matches("toysManufactured\\[\\d\\]\\.name"))
                        {
                                log.debug("found a toy manufactured");
                                toysManufacturedCount++;
                        }
                }
                
                for (int i = 0; i < toysManufacturedCount; i++)
                {
                        Toy toy = new Toy();
                        o.addToyManufactured(toy);
                        log.debug("added toy manufactured to toy provider");
                }
                
                return o;
        }

Thanks!

Greg



Mike Horwitz wrote:
> 
> On 9/7/07, gederer <[EMAIL PROTECTED]> wrote:
>>
>>
>> Looks like there are problems with LazyList and Hibernate:
>>
>> http://forum.springframework.org/showthread.php?p=140315
>> http://forum.springframework.org/showthread.php?p=140315
>>
>> Could I avoid LazyList by overriding a Spring controller method. Looking
>> at
>> the docs, I see that bindAndValidate() is a final method. Any thoughts?
>>
>> Greg
>>
>>
>>
>> gederer wrote:
>> >
>> > Thanks for the reply.
>> >
>> > I've seen this page. It provides a useful starting point; though, it
>> > doesn't specifically address building forms dynamically in the browser
>> (it
>> > builds forms dynamically in JSP).
>> >
>> > If I just add form elements with names like
>> > commandObj.collection[index].propName, will my SimpleFormController
>> > subclass do the right thing?
>> >
> 
> 
> Yes. Just be careful to follow the proper naming convention....
> 
>> Also, do you know whether LazyList is compatible with Hibernate
>> > collections? The javadoc says that LazyList.decorate() returns a List.
>> > But, obviously, this must be a concrete class instance. Not sure what
>> type
>> > of list this is.
> 
> 
> Really not sure on this one! Perhaps someone else can comment? I would say
> it is definitely worth a try before resorting to doing things manually in
> the controller.
> 
> Mike
> 
>>
>> > Thanks!
>> >
>> > Greg
>> >
>> >
>> > Mike Horwitz wrote:
>> >>
>> >> Presumably you would hold the references to the addresses in a list,
>> in
>> >> which case you simply use an index to reference them and Spring will
>> be
>> >> able
>> >> to bind your objects at will. An example/discussion here:
>> >> http://mattfleming.com/node/134
>> >>
>> >> Mike
>> >>
>> >> On 9/7/07, gederer <[EMAIL PROTECTED]> wrote:
>> >>>
>> >>>
>> >>> Hi,
>> >>>
>> >>> I have a form that requires managing master-detail relationships. A
>> >>> simplified example would be a person form where a person can have
>> many
>> >>> addresses. What I'd like to to do is use JavaScript to add new
>> address
>> >>> detail sub-forms to the person form on the same page.
>> >>>
>> >>> So, the user would click an 'Add Address' button, and a new address
>> >>> detail
>> >>> form would appear. The user would be able to add any number of
>> >>> addresses,
>> >>> and they would all get submitted along with the person data when the
>> >>> user
>> >>> submits the form.
>> >>>
>> >>> I can handle the JavaScript part. But, I'm not sure exactly how the
>> >>> address
>> >>> data should appear in the query string (what name=value pairs I
>> should
>> >>> send), or what the controller code should look like.
>> >>>
>> >>> I have done some googling, but have not found a complete solution.
>> Has
>> >>> anyone done this sort of thing? I'd be grateful for any suggestions.
>> >>>
>> >>> Thanks!
>> >>>
>> >>> Greg
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/Dynamic-forms-with-Spring-MVC-tf4396661s2369.html#a12537445
>> >>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >>> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Dynamic-forms-with-Spring-MVC-tf4396661s2369.html#a12538046
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Dynamic-forms-with-Spring-MVC-tf4396661s2369.html#a12604696
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to