/**
* This method gets called when the user clicks on an item in the listing.
*/
public void process() {
/* retrieve the item selected and wrap it in a bean wrapper. */
BeanWrapper child = new BeanWrapperImpl(clickedItem);
if (!toParent) {
/* Set the selected id into child. */
child.setPropertyValue(super.targetProperty, getParentId());
} else {
getParent().setPropertyValue(super.targetProperty, child.getPropertyValue(super.sourceProperty));
}
/* Unselect whatever was selected. */
if (!toParent) {
Set<T> unselectedChildren = getSelectedChildren();
for (T unSelect : unselectedChildren) {
BeanWrapper unChild = new BeanWrapperImpl(unSelect);
unChild.setPropertyValue(super.targetProperty, null);
}
/* Merge the changes with the database. */
updateChildren(unselectedChildren);
} else {
//