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 13:35:12 -0700 (PDT)
Mark: Thanks for your reply. I was able to get the setItemSelected() method to execute. I have one more issue, as follows:
Basically, the WOCheckBox is embedded in a WORepetition. These are part of one page, let's call it Display.wo. Display.wo the functionality of showing a list of individual names, with checkboxes appearing beside them.
___________________________________________________________________
Display.wo
CheckBox 1 Individual 1
CheckBox 2 Individual 2
CheckBox 3 Individual 3
etc....
____________________________________________________________________
Display.wo is then called from a separate WebObjects file, let's call it Edit.wo. This is done for the purpose of generating a nice scrolling bar to help navigate through the list. Edit.wo offers several
modfication buttons... Edit, Delete, Add.
____________________________________________________________________
Edit.wo
Please search for your individual ___
TEXTBOX__________
***********************************************************************************************
Display.wo
CheckBox 1 Individual 1
CheckBox 2 Individual 2
CheckBox 3 Individual 3
etc....
*********************************************************************************************
EditButton DeleteButton AddButton
_____________________________________________________________________
The problem lies here. Clicking edit, delete, or add... will not submit the form for
Display.wo, since they are part of a separate .wo file. Instead of I've added an onClick attribute to my WOCheckBox, which successfully is able to invoke the setItemSelected() method.... but only when it is checked (not when unchecked). How do I call setItem Selected() when unchecking a WOCheckBox? Or, is there a way to submit an inner page, by clicking a button from the outer page?
Thanks,
Mike
Mark Morris <email@hidden> wrote:
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:
This email sent to email@hidden