Announcement Announcement Module
Collapse
No announcement yet.
Deletion in ArrayList Dynamic Binding Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deletion in ArrayList Dynamic Binding

    Hi,

    I have found a very good explanation about adding a new element into an ArrayList dynamic binded to a jsp page by CommandController:

    http://mattfleming.com/node/134
    http://mattfleming.com/node/235

    However, does anyone know how to remove an element from the ArrayList by means like clicking the "Delete Row" button on the jsp page? So that the CommandController will detect the deletion and dynamically shrink the ArrayList.

    Any opinion is welcomed! Thank you very much.

    Timothy
    Last edited by timothy chan; Jun 14th, 2010, 02:22 AM.

  • #2
    If you want to delete the listItems[x] object, I think what is enough is to simply remove it from the form (prevent the item from being submitted) , and the binded value will be empty/null.

    Comment


    • #3
      Hi Weissed,

      Your reply is very appreciated. I understand your point and I will try it. I have a few questions regarding your suggestion.

      Since the element in the ArrayList may not be a simple string or integer value only, instead it maybe an object with certain fields. There maybe several textboxes or checkboxes for each of the element in the ArrayList. Do you mean that if I want to remove 1 element from the ArrayList, I need to remove all fields relating to that specific 1 element from the form in order to make the element become null? including the hidden fields containing the primary key in the jsp form.

      Also if I make the element null, I have no way to trace back the primary key and delete the coresponding row in database after submitting back to the CommandController, am I correct?

      Yes, the questions are a little bit complicated. Hope that you don't mind to tell me if you have any idea, haha : >

      Thank you very much.

      Comment


      • #4
        Do you mean that if I want to remove 1 element from the ArrayList, I need to remove all fields relating to that specific 1 element from the form in order to make the element become null? including the hidden fields containing the primary key in the jsp form
        Yes, exactly

        But if you need to remove the entity as well as the reference to the entity in the collection, then maybe the aproach that submits that form data containing the new collection is not the best.
        Why not a request that deletes the specific entity only?

        Comment

        Working...
        X