• 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: Getting Selected Values from Subcomponents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Selected Values from Subcomponents


  • Subject: Re: Getting Selected Values from Subcomponents
  • From: Samuel Pelletier <email@hidden>
  • Date: Wed, 28 Jan 2015 12:27:17 -0500

Hi,

The usual way is to have a binding in the MyList component that will contain an array of selected items, you may call it "selectedItems". For the action, is is better to have also have a binding to create a real reusable component. A component should never assume it's parent type to be really reusable.

To use a binding for action, you need to disable the auto synchronisation with this override:
@Override
public boolean synchronizesVariablesWithBindings() {
return false;
}

If the list of items to display come from the parent, you get the value in a method with valueForBinding("items") for example.

The MyList action method will look like this:
public WOActionResults selectContact() {
setValueForBinding(selectedItems(), "selectedItems");  // Send the array to parent
return (WOActionResults) valueForBinding(SelectActionBindingName);  // call the parent bound action and return it's result
}

It is quite simple to use, the parent component will look like this:
<wo:MyList action="" selectedItems="$selectedItems" />

Samuel

Le 2015-01-28 à 06:46, Daniele Corti <email@hidden> a écrit :

Hi list, 
I don't know if what I want to do is the best approach:

I would like to create a Main Component Page that call a reusable SubComponent

Example:

MyPage.wo:
     <h1>My Page</h1>

     <wo:form multipleSubmit="$true">
         <wo:submitButton action="">Do It!</wo:subimtButton>
         <wo:MyList></wo:MyList>
    </wo:form>

in the Subcomponent there is a List of Checkbox

MyList.wo:
    <ul>
         <wo:loop list="$myList" item="$myItem">
         <li><wo:checkBox selection="$mySelection" value="$true"></wo:checkBox></li>
         </wo:loop>
    </ul>

I would like to obtain the checked objects of the subcomponent, but I don't know how can I get the subcomponent from the Parent MyPage.

I know I can put the button in the subcomponent and call performParentAction, but I would like to put all the logic inside the MyPage component, and simply display values in the MyList component.

Is this possible (first of all)? And, if so, how can I reach subcomponents from parent?

Thank you in advance!
 
--
Daniele Corti
--
I DON'T DoubleClick
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: 
 >Getting Selected Values from Subcomponents (From: Daniele Corti <email@hidden>)

  • Prev by Date: Re: Webobjects-dev Digest, Vol 12, Issue 41
  • Next by Date: Qualifier involving many-to-many relationship
  • Previous by thread: Re: Getting Selected Values from Subcomponents
  • Next by thread: Re: Webobjects-dev Digest, Vol 12, Issue 41
  • Index(es):
    • Date
    • Thread