...
Defining which updatable collections have deletable elements
org.kuali.ricekfs.kns.bo.PersistableBusinessObject.buildListOfDeletionAwareLists()
should be implemented for all business objects that require deletion of removed elements.
In a nutshell, this method returns a List
of Collection
of a BO. It returns a list of references to the actual collections storing data. Given a BO from the form to persist, it retrieves the corresponding BO from the database (based on primary key). Compares the collections returned by buildListOfDeletionAwareLists()
, and deletes any elements contained within the DB-based BO and not in the form-based BO.
...
- Have the DAO class implement
org.kuali.ricekfs.kns.util.OjbCollectionAware
- In the method that saves/updates the business object (e.g. save), retrieve the corresponding business object from the database with the same primary key values.
- Retrieve the
org.kuali.ricekfs.kns.util.OjbCollectionHelper
bean from the Spring bean factory. In rice, useKNSServiceLocator.getOjbCollectionHelper()
and in KFS or Rice client code, useSpringContext.getBean(OjbCollectionHelper.class)
. - Call
org.kuali.ricekfs.kns.util.OjbCollectionHelper.processCollections(OjbCollectionAware theDAO, PersistableBusinessObject boFromForm, PersistableBusinessObject boFromDatabase)
- Store the BO from the form as normal (typically by calling
getPersistenceBrokerTemplate().store(document)
).
...