Hi, Thanks for the input guys. I ended up solving it with @Before and @After annotations that clears the list before binding and compacts (remove null entries) it after binding. Seems to work fine.
-dennis Ben Gunter <[email protected]> skrev den 25-06-2009 14:44:18: > It's generally a bad idea to do the following, even though it's really easy: > 1. Load a list into your ActionBean and forward to a view with > inputs for properties of the list elements. > 2. Modify the elements and submit to same ActionBean > 3. Before binding, load the list the same way as in #1 > 4. Allow Stripes to bind the properties into the list elements > The reason it's a bad idea is that the list often can change between > the time the view is presented and the time the form is submitted. > Then you'd be binding property values to the same indexes, but there > might be a different object at that index in the list due to the changes. > > You can do something very similar except that you do NOT load the > list again (step 3 above) on form submission. Instead, you include a > hidden input that specifies which object to load into the list at > the given index. E.g. <s:hidden name="things[0]" />. If you're using > Stripersist (or some other good TypeConverter/Formatter combination) > then Stripes will populate the input automatically. When you submit > your form, each element will get stuffed into the list by the type > converter and property binder and you'll know exactly what object > you're modifying with inputs like things[0].name and things[0].description. > > And that's where Mike's comment is relevant. If you don't submit any > inputs for things[1] (but you do have a things[2]) then that > position in the list will be null and you'd need to compact it to > remove the nulls. > > -Ben > On Thu, Jun 25, 2009 at 3:25 AM, <[email protected]> wrote: > > Hi, > > But as far as I can tell, there is no way to see which entries (if > any) were deleted from the list? > > Since the setter method actually takes a list I would think it was > cleared before putting the new values (from the request) in it? > > -dennis > > Mike McNally <[email protected]> skrev den 24-06-2009 15:31:32: > > > > In this exact situation, I ended up "packing" my list in my data-layer > > code. Our (home-grown) JPA layer provides for a "beforeSave" hook in > > the DAO, so in there I make sure the list is contiguous. > ------------------------------------------------------------------------------ > _______________________________________________ > Stripes-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
_______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
