Announcement Announcement Module
No announcement yet.
Dynamic Lists + Property Editors ouch Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic Lists + Property Editors ouch

    Hi all,

    I have combined the two and have not survived entirely unscathed. Following advice such as, my dynamic list form complete with javascript gets the values populated.

    In my formBackingObject method, I create the backing bean via a database call using LazyList from apache commons for my bean attributes which are dynamic lists.

    I have an initBinder method which registers my custom editors. The setText gets invoked when I do form submissions. The getText gets invoked when I have <spring:bind> tags around my fields on my "success pages". So my custom editor is fine, I know.

    In my onSubmit method I take the Object command which is passed in an store that to the database and everything is stored fine.

    When I go to a "success page" and try display a dynamic list this is what happens. If I remove an item (say I had 2 in my database and I downsize to 1) everything happens correctly. My database now has 1 item and my "success page" says I have one item. If I have 1 item and try to add a second item, the 1st item will be displayed and a blank 2nd item will be displayed (as the lazy list kicks in) although the 2nd items ends up in the database and will be displayed on my "success page" if I push browser refresh. Here is the gotcha about my situation:

    My success page uses the following style:
    <c:for items="${myItems}" varStatus="loop">
    <spring:bind path="myItems[${loop.index}].personId">

    The bind is NECESSARY because personId is a BigDecimal, but I need to display the NAME associated with id number. This occurs via a lookup table in the database so this is not something which is lying around in memory. Without the bind, I would get a list of 2 Big Decimals under my add scenario above (the correct answer, what I expect from my dynamic list), but with the bind I only get the 1st element and then a LazyList generated second element which as I said is empty.

    This likely occurs because the binding occurs from the object generated in the formBackingObject (what WAS in the database before). For whatever reason I am not able to use the property editor binding for my newly generated items in my dynamic list.

    So I need to figure out how to get this newly selected data in my dynamic list to be displayed, and to be displayed in the correct format with minimal hackage. Any comments?

    (Thanks for reading, sorry it is long, but I have played around a lot before posting).