Re: WORepetition, checked attribute question
Re: WORepetition, checked attribute question
- Subject: Re: WORepetition, checked attribute question
- From: "Jerry W. Walker" <email@hidden>
- Date: Wed, 25 Oct 2006 23:28:21 -0400
Hi, Mike,
Sorry I didn't get back to you sooner, but I was with a client and
offline all day. However, it looks like others have answered your
questions in about the same way I would have.
I might only add to what Mark Morris and David LeBer mentioned to you
that if you put the WOForm dynamic element in your Edit.wo page and
embed the Display.wo component in the section of the Edit.wo page
that is wrapped by the WOForm, the browser will neither know nor care
that you're using two components. It only cares that the form
elements (of Display.wo) are wholly contained within the HTML form
(that is, the WOForm dynamic element of Edit.wo).
You can easily see this in most browsers by rendering your page in
the browser and using the browser to display the source for the page.
When a submit button is clicked within the scope of the HTML form
that's generated by the WOForm element, the browser will send the
input values also embedded within that HTML form back to the server.
WO is very good about keeping track of where those values are
supposed to end up, whether in the component or in the subcomponent.
HTH.
Regards,
Jerry
On Oct 25, 2006, at 1: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
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
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