Hi Jerry:

I'm having trouble understanding how to call the method that you defined, setItemSelected().  Does this somehow occur once the page is submitted?  Or do I need to call this method from an onClick attribute?

Thanks for your help so far!

-Mike




=======================================
public NSArray itemList;
public Item currentItem;
public NSMutableArray selectionList;

// Presume that itemList and selectionLists have been initialized.

public boolean itemSelected()
{
return selectionList.containsObject(currentItem);
}

public void setItemSelected(boolean value)
{
// is the Item already on the selection list?
boolean oldValue = itemSelected();

        // if selected, and not already on the list, add
 it
if (value && !oldValue)
selectionList.addObject(currentItem);

        // if not selected but already on list, remove it
else if (!value && oldValue)
selectionList.removeObject(currentItem);

        // if selected and already on list, do nothing
// if not selected, but not on list, do nothing
}
=======================================

For the WORepetition, bind the currentItem to the "item" binding, bind the itemList to the "list" binding.

For the iterated WOCheckBox, bind itemSelected to the "checked" binding. This, of course, binds to the two accessor methods for which there is no instance variable. The get accessor simply checks to see whether the item is in the selected list. The set accessor deals with the four cases:

is
 checked    on selection list      action
true true do nothing
true false add to list
false true remove from list
false false do nothing

That's it, simple, fast and elegant.

Regards,
Jerry
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to