Hello everyone,

I'm working a tiny little RSVP for a friend. While doing so I found, what seems to me at least, a very non-intuitive result from the For component. Basically the behavior I want is:

1. The user navigates to the RSVP page and is provided a drop down box to select the number of people who will be attending the event.

2. The user is given a list of text entry boxes (to enter the name of the guest) and drop downs (to select the meal the guest wants).

1 was simple to accomplish though having to create a PropertySelectionModel is kinda a pain for something this simple. Where things got hairy is 2. Basically the code flow is: in the listener for the form submit in #1, I grab the number of guests attending and set that on the meal selection page. The meal selection page's pageBeginRender creates a List of x RSVP objects where x is the number of guests attending. Then the meal selection page uses a For component to loop through the List of RSVP objects so that, in the first pass everything is blank and then when the guest submits, those RSVP objects in the List get filled in with the details the guest entered.

Now, what actually happened is the first RSVP object in the list is continually updated over and the others are never touched. When tracing through the For components code, it appears to be trying to match the serialized object saved in the form against the ones in the List to "intelligently" pick which one to update. But since all of the RSVP objects were the same to start with, and the For component doesn't update it's internal mapping after updating an object, it just ignored everything in the list after the first item. Or, I guess more accurately, it continually matched the first item in the List and so it just repeatedly updated that one RSVP object. To work around this, I needed to set the RSVP's id in the pageBeginRender to a different value for each RSVP object and then reset them back to 0 just before sending them to Hibernate to persist (if I don't reset them to 0, Hibernate things it's a detached object and ends up updating a row instead of adding a new row).

This work around seems very much like a hack to me. Is there a way to make the For component do the right thing (i.e. actually iterate over the array when rewinding instead of assuming it knows what it's doing)? I did try playing with the match parameter and that completely breaks everything, none of the objects in the List get updated. It seems that my use case isn't so terribly strange that it would be this difficult to accomplish in Tapestry.

Thanks,
--Chris

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

Reply via email to