supplying an initial selection in WOPopUpButton and its kin
supplying an initial selection in WOPopUpButton and its kin
- Subject: supplying an initial selection in WOPopUpButton and its kin
- From: Joe Little <email@hidden>
- Date: Tue, 20 Jul 2004 16:17:19 -0700
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. 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
In my class constructor for the overall WOComponent, I initialize both
the values:
public edit_user(WOContext context) {
super(context);
labs = getLabs();
itemLab = getSelectedLab();
However, my PopUp always displays "Select a Lab". Currently,
getSelectedLab() is:
public Lab getSelectedLab()
{
selectedLab = new Lab();
java.util.Enumeration enumerator = labs.objectEnumerator();
while (enumerator.hasMoreElements()) {
Object testLab = enumerator.nextElement();
try {
if (((Lab)testLab).id().intValue() == selectedUser.id().intValue()) {
selectedLab = (Lab)testLab;
}
} catch (Exception e) {
return selectedLab;
}
}
return selectedLab;
}
Hairy, but should do the job. Anything obviously wrong in my thinking
of how to initiate a selection?
_______________________________________________
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.