Re: WORepetition, checked attribute question
Re: WORepetition, checked attribute question
- Subject: Re: WORepetition, checked attribute question
- From: Chip Myers <email@hidden>
- Date: Wed, 25 Oct 2006 10:41:53 -0700 (PDT)
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden