| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Mike,
When a WOForm is submitted, the values in the form are pushed into
your application using the value bindings you specified. If you bind
a variable, it's clear that the variable value is set. However, you
don't have to bind variables, you can also bind methods. In the case
below, if you bind "itemSelected" to "checked", when the page is
displayed WO will get the value from the itemSelected() method, and
when the form is submitted WO will set the value using the
setItemSelected( boolean ) method. You don't have to do anything but
observe the naming convention.
Also, to add my 2 cents, Jerry's approach is the one I use. That
approach in general lets you map between what's in the data and
what's presented to the user, whether it's a checkbox or any other
form item, to let you use what makes sense on each side without
compromising either. (Did that make sense...?)
Regards,
Mark
On Oct 25, 2006, at 12:41 PM, Chip Myers wrote:
> 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: http://lists.apple.com/mailman/options/webobjects-dev/email@hidden This email sent to email@hidden
| References: | |
| >Re: WORepetition, checked attribute question (From: Mark Morris <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.