Selecting a subset of Objects in a WORepetition

Often you need to allow a user to select a subset of items from a WORepetition to be able perform an action on them. This example will do that for you:

public Object item; // The "item" binding on your WORepetition
public NSMutableArray selections = new NSMutableArray();
 
public void setSelectedItem(boolean selected) {
    boolean hasItem = selections.containsObject(item);
    if (selected) {
        if (! hasItem) {
            selections.addObject(item);
        }
    } else if (hasItem) {
        selections.removeObject(item);
    }
}
	
public boolean selectedItem() {
    return selections.containsObject(item);
}

Add a WOCheckbox to your WORepetition and bind its checked binding to selectedItem. Any item selected will be added to the selections array when the form is submitted.