RE: Newbie: NonDirect Java - Using Popup Menus in Nib Files
RE: Newbie: NonDirect Java - Using Popup Menus in Nib Files
- Subject: RE: Newbie: NonDirect Java - Using Popup Menus in Nib Files
- From: "Pierre Bernard" <email@hidden>
- Date: Wed, 19 Mar 2003 18:00:05 +0100
- Thread-topic: Newbie: NonDirect Java - Using Popup Menus in Nib Files
I don't know what the tutorial wants you to do with the _illustrator variable. But I would guess later code will depend on that. Code you will have to write.
For the second example you would need to set the selected object in the display group that holds the list of County. You can do that much like you did with _illustrator and use the selected index binding/aspect.
I however prefer to work with the selectedObject aspect as this results in less code. However you need the following patch to do that:
/** Subclass of EODisplayGroup meant to be used as a controller display group.<BR>
*
* The behavior of the parent class is modified so that this display group no longer relies on
* its objects implementing the EORelationshipManipulation interface. Thus it becomes possible
* to use associations to bind a pop-up menu to a controller.<BR>
*
* Actually it would probably be best to patch EOValueSelectionAssociation._storeSelectionValue(),
* but that would prevent us from creating the associations in InterfaceBuilder. Moreover there
* might be other associatons exhibiting the same behavior. One fix to rule them all.<BR>
*
* In order to use this display group rather than the default one add the following to you
* subclass of EOArchiveController:
* <CODE>
* public EODisplayGroup controllerDisplayGroup()
* {
* if ( ! hasControllerDisplayGroup())
* {
* EODisplayGroup displayGroup = new EODisplayGroup();
*
* setControllerDisplayGroup(displayGroup);
* }
*
* return super.controllerDisplayGroup();
* }
* </CODE>
*
* @author bernard
* @version ControllerDisplayGroup.java,v 1.1 2003/03/19 16:35:57 bernard Exp
**/
public class ControllerDisplayGroup extends EODisplayGroup
{
/** Overridden method.
* @see com.webobjects.eointerface.EODisplayGroup#_addObjectToBothSidesOfRelationshipWithKeyAtIndex(java.lang.Object, java.lang.String, int)
**/
public boolean _addObjectToBothSidesOfRelationshipWithKeyAtIndex(Object value, String key, int index)
{
Object object = displayedObjects().objectAtIndex(index);
if (object instanceof EORelationshipManipulation)
{
return super._addObjectToBothSidesOfRelationshipWithKeyAtIndex(value, key, index);
}
else
{
return super.setValueForObjectAtIndex(value, index, key);
}
}
/** Overridden method.
* @see com.webobjects.eointerface.EODisplayGroup#_removeObjectFromBothSidesOfRelationshipWithKeyAtIndex(java.lang.Object, java.lang.String, int)
**/
public boolean _removeObjectFromBothSidesOfRelationshipWithKeyAtIndex(Object value, String key, int index)
{
Object object = displayedObjects().objectAtIndex(index);
if (object instanceof EORelationshipManipulation)
{
return super._removeObjectFromBothSidesOfRelationshipWithKeyAtIndex(value, key, index);
}
else
{
return super.setValueForObjectAtIndex(null, index, key);
}
}
}
-----Original Message-----
From: Martin Spenceley [mailto:email@hidden]
Sent: Wednesday, March 19, 2003 5:23 PM
To: email@hidden
Subject: Newbie: NonDirect Java - Using Popup Menus in Nib Files
Hello again,
I am having a lot of problems trying to use Popup Menus in NIB files.
In the latest documentation there is an example on how to do this. But I get lost at the last paragraph:
> In the nib file?s controller class, add a method called setKey. This is invoked when an object in the pop-up menu is > selected.
>publicvoid setKey(int illustrator) {
> _illustrator = (String)controllerDisplayGroup().valueForObjectAtIndex(illustrator, "name");
>}
> It sets an instance variable in the class (_illustrator) to the String value of the object selected in the menu.
What am I supposed to do with the _illustrator information now I've got it? How do I get it into an 'Image Search?'? I assume this has to be hard coded from then on?
The second problem is the following scenario:
I have a multi-related schema of the form:
Country -> Town -> Street -> House
e.g. Country is related to town ( in a one to many relationship) etc....
In my interface, I want to select a Country from a popup menu which will show a list of towns in a TableView.
If I use a NSTableView for the Country, the Towns appears
in the next Table without issues. If I try to use the JCStudios example with their Popup Menu, most often the Popup menu is
just grayed out or becomes grayed out. This is sort of understandable (though don't ask me to explain it!).
Would I be right in saying I cannot use a Popup Menu for the purpose I want? If not, I need to do something along the
lines of the written example or can I do everything in the NIB?
Regards,
Martin
_______________________________________________
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.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
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.