Menu

Remove

Help
Mery
2010-09-24
2013-05-02
  • Mery

    Mery - 2010-09-24

    Hi, I have a problem with the application to see if someone can help me.

    In my application I have something similar to this:

    public class garage extends AbstractDomainObject {

    private List<Cars> cars = new ArrayList<Cars>();
    }

    And inside the class Cars I have another arraylist like this:

    public class Cars extends AbstractDomainObject {

    private List<Color> colors = new ArrayList<Color>();

    When I remove a item of Cars class that it has some items associated of Colors class, then I have a error when I want read this items of Colors class. I need that this items also removed when I called to this method for remove item of Cars class:

    public void removeFromCars (Cars item){
        cars.remove(item);
        }

    How can I do?

     
  • Alexander Krasnukhin

    You want to autoremove all Color objects with Cars object, don't you?

     
  • Mery

    Mery - 2010-09-24

    Yes, it is. ¿How can I do that?

     
  • Alexander Krasnukhin

    You can use removing() method. It will be invoked before object is really removed from object store. So you could clear colors collection & remove all Color objects before Cars object is removed. Please, read more there http://www.nakedobjects.org/applib/recognised-methods.html

     
  • Mery

    Mery - 2010-09-24

    I tried with this, but didnt work:

        public void clearCars(){
       
        cars.clear();
        };

        public void removing(Cars item){
       
        cars.remove(item);
        clearCars ();
        }

    Which can be the problem?

     

Log in to post a comment.