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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
You want to autoremove all Color objects with Cars object, don't you?
Yes, it is. ¿How can I do that?
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
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?