Re: CORRECTION: Re: More newbie questions
Re: CORRECTION: Re: More newbie questions
- Subject: Re: CORRECTION: Re: More newbie questions
- From: Lachlan Deck <email@hidden>
- Date: Sat, 19 Nov 2005 08:18:33 +1100
Hi there,
On 18/11/2005, at 5:48 PM, Randy Becker wrote:
I'm using a WORepetition currently. It displays objects I want it to,
Good.
Actually this kind of stuff comes up in the Apple tutorials (I think)
- so have you been through the "Web Applications" tutorial from the
following?
http://developer.apple.com/referencelibrary/DeveloperTools/
idxWebObjects-date.html
but I need to be able to perform actions on a user-selected subset
of the objects it displays. Is a WORepetition not a good way to do
this?
A WORepetition is very commonly used. e.g., say you have a list of
items displayed where each one has a checkbox for the user to (un)check.
The bindings for your repetition might be something like:
MyRepetition: WORepetition {
list = someList;
item = anItemOfList; /* used as an iterator */
}
And the bindings for each item:
AnItemCheckbox: WOCheckBox {
checked = isChecked;
}
Just below them you have a WOSubmitButton and all of these are
wrapped in a WOForm.
Now, bind the WOSubmitButton to the action you want to perform and
when the form is submitted whatever you've bound the "checked" to
will get called but this time the setter method is called instead of
the getter used to display the page. This all happens just prior to
the action being given control.
Your Java code can look something like:
public class MyComponent extends WOComponent {
/* TypeInfo TypeOfAnItem */
NSMutableArray someList;
TypeOfAnItem anItemOfList;
NSMutableArray theItemsToUseAfterFormSubmit;
public MyComponent(WOContext context) {
super(context);
someList = null;
theItemsToUseAfterFormSubmit = new NSMutableArray();
}
/* TypeInfo TypeOfAnItem */
public NSMutableArray someList() {
if ( someList == null ) {
// populate
}
return someList;
}
public Boolean isChecked() {
return anItemOfList.isChecked();
}
public void setIsChecked( Boolean value ) {
if ( value.booleanValue() ) {
if ( ! theItemsToUseAfterFormSubmit.containsObject
( anItemOfList ) ) {
theItemsToUseAfterFormSubmit.addObject( anItemOfList );
}
}
else if ( theItemsToUseAfterFormSubmit.containsObject
( anItemOfList ) ) {
theItemsToUseAfterFormSubmit.removeObject( anItemOfList );
}
}
public WOComponent myAction() {
WOComponent nextPage;
nextPage = ( NextComponent)pageWithName( "AName" );
// now do with it what with:
// theItemsToUseAfterFormSubmit
return nextPage;
}
}
with regards,
--
Lachlan Deck
_______________________________________________
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