001    package net.databinder.components;
002    
003    import java.util.Collection;
004    
005    import org.apache.wicket.markup.repeater.Item;
006    
007    /** Removes the given item from its collection. */
008    public class RemoveRepeaterItemButton extends RepeaterItemButton {
009       
010       public RemoveRepeaterItemButton(String id, Item item) {
011          super(id, item, getTrashImage());
012       }
013       
014       @Override
015       public void onSubmit() {
016          Collection c = (Collection) getView().getModelObject();
017          if (c != null) {
018             getView().modelChanging();
019             // depends on correct equals()!
020             c.remove(item.getModelObject());
021             getView().modelChanged();
022          }
023       }
024    }