• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ComponentContent, iterator and item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ComponentContent, iterator and item


  • Subject: Re: ComponentContent, iterator and item
  • From: Zak Burke <email@hidden>
  • Date: Tue, 30 Nov 2004 08:18:34 -0500

arturo,

Your question is a little tricky because a form's action is a method name, not a value (such as a String) that can be passed around. There is still a way to do what you want, I think. Here's a long explanation; the form-related part is covered at the end but I had to work through the whole example first.

You have a container within which you want to loop over a list and display the list items with a subcomponent. You should have Java files like these:

Container.java
	public NSArray    barArray;
	public ItemObject aBarItem;
	...

ItemDetail.java
	public ItemObject item;
	...

Container.wod should look like this:
	aList: WORepetition {
	        list = barArray;
	        item = aBarItem;
	}
	itemDetails: ItemDetail {
	        item = aBarItem;
	}

Container.html should look like this:
	<WEBOBJECT NAME=aList>
	        <WEBOBJECT NAME=itemDetails></WEBOBJECT>
	</WEBOBJECT>

ItemDetail.wod and ItemDetail.html would be just like any other component, containing all the formatting details for ItemObjects.

The key is the second part of Container.wod: the itemDetails variable is of type ItemDetail (the classname of the nested component) and assigns the list-variable (listItem) to a member of that class (item). You can assign any number of values on the child component from the parent in this way.

To have a submit button on a nested component call a method on the parent, the nested component class needs to have a reference to the parent. I don't know if you can use "this" in .wod files, in which case this example would be simpler, but here's the long way of doing things:

Container.java
	public NSArray    barArray;
	public ItemObject aBarItem;
	public Container getMyself() { return this; }
	public WOComponent save() { ... }
	...

ItemDetail.java
	public ItemObject item;
	public Container parentItem;
	...

Container.wod
	...
	itemDetails: ItemDetail {
		item = aBarItem;
		parentItem = getMyself;
	}

ItemDetail.wod
	saveButton: WOSubmitButton {
		action = parentItem.save;
		value = "Add Record";
	}

zak.


Arturo Pérez wrote on 11/29/04 10:49 PM:
Hi folx,

I'm trying something I haven't tried before and I'm kinda stuck. Any advice would be appreciated.

I've created a nested component that contains a WOComponentContent within a WORepetition. The content I'm envisioning is submit buttons for a form. So, basically, I pass an array to the nested component, which iterates over it creating a bunch of submit buttons for me. The action for the submit button comes from the parent component. Let's call the array barArray and the item iterator variable is aBarItem.

The question is basically: Within that parent's action how do I get the value of aBarItem the way one would if one were using just a WORepetition?

I've printed the value of parent from the nested component and it is what I would expect. But the iterator variable (aBarItem) always seems to be null.

BTW, I've read the following and although the explanation seems lucid and apropos I don't see how to apply the ideas to my situation. Maybe I'm too tired :-)
http://www.omnigroup.com/mailman/archive/webobjects-dev/2001-August/ 013696.html


--arturo

_______________________________________________
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

_______________________________________________
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


References: 
 >ComponentContent, iterator and item (From: Arturo Pérez <email@hidden>)

  • Prev by Date: Re: ComponentContent, iterator and item
  • Next by Date: Blank Page on Deployment
  • Previous by thread: Re: ComponentContent, iterator and item
  • Next by thread: Monitor can't access wotaskd!
  • Index(es):
    • Date
    • Thread