• 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: supplying an initial selection in WOPopUpButton and its kin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: supplying an initial selection in WOPopUpButton and its kin


  • Subject: Re: supplying an initial selection in WOPopUpButton and its kin
  • From: Art Isbell <email@hidden>
  • Date: Tue, 20 Jul 2004 15:30:52 -1000

On Jul 20, 2004, at 1:17 PM, Joe Little wrote:

I've used PopUps before, where I presented a NSArray of items,
provided and initial display string, and dealt with the return value.
What I am seemingly not understanding is how to set an initial value
if one is already previous selected.

Not quite sure what you mean. The initial value is merely the value of the key bound to the pop-up's "selection" key.


My example is that I want to
assign Lab EOs to my Users. In WOPopUpButton I set this info:

displayString itemLab.labName
item itemLab
list labs
noSelectionString "Select a Lab"
selection selectedLab

To assign an initial selected value, assign a Lab to selectedLab. This can be done in the component's constructor, for example.


In my class constructor for the overall WOComponent, I initialize both
the values:

    public edit_user(WOContext context) {
        super(context);
		labs = getLabs();
		itemLab = getSelectedLab();

itemLab shouldn't be explicitly assigned. The pop-up dynamic element will assign itemLab.


However, my PopUp always displays "Select a Lab". Currently,
getSelectedLab() is:

	public Lab getSelectedLab()
	{
		selectedLab = new Lab();

selectedLab shouldn't be assigned to a new, empty Lab object. It should be initialized to null.


java.util.Enumeration enumerator = labs.objectEnumerator();
while (enumerator.hasMoreElements()) {
Object testLab = enumerator.nextElement();
try {
if (((Lab)testLab).id().intValue() == selectedUser.id().intValue()) {

Looks like you're accessing primary and maybe foreign keys which isn't normally done. I don't know your eomodel, but maybe a User has a Lab. If so, User has a "lab" relationship. If true, the test would be


					if (testLab.equals(selectedUser.lab())) {

					selectedLab = (Lab)testLab;
					}
				} catch (Exception e) {
				return selectedLab;
				}
			}
		return selectedLab;
	}

Aloha, Art _______________________________________________ webobjects-dev mailing list | email@hidden Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: supplying an initial selection in WOPopUpButton and its kin
      • From: Joe Little <email@hidden>
References: 
 >supplying an initial selection in WOPopUpButton and its kin (From: Joe Little <email@hidden>)

  • Prev by Date: [OT] WO Books for Uni Students
  • Next by Date: Re: [OT] WO Books for Uni Students
  • Previous by thread: supplying an initial selection in WOPopUpButton and its kin
  • Next by thread: Re: supplying an initial selection in WOPopUpButton and its kin
  • Index(es):
    • Date
    • Thread