Re: Setting a Default toOne Relationship
Re: Setting a Default toOne Relationship
- Subject: Re: Setting a Default toOne Relationship
- From: David Avendasora <email@hidden>
- Date: Fri, 19 May 2006 09:35:19 +0100
I'm don't really know, I guess.
I've been following the instructions in the WebObjects Java Client
Programming manual (http://developer.apple.com/documentation/
WebObjects/DesktopApplications/WODesktopApps.pdf) for "Enhancing the
Application" in which it describes several ways to modify a Direct To
Java Client application. In the instructions for setting initial
values (page 123), the example code is put in the awakeFromInsertion
(EOEditingContext) method in the server-side class. I was putting it
in the client-side, but I've now generated server side classes, added
it to the Application Server target and put the code there and even
changed it to simply put a default value in one of the attributes
instead of setting a relationship, but it still doesn't work.
Here's what my code now looks like
public void awakeFromInsertion (EOEditingContext ec) {
super.awakeFromInsertion(ec);
System.out.println("Routing awakeFromInsert Called");
if (routingDescription() == null) {
setRoutingDescription("Description");
}
}
When I click the new icon for a routing and I get the form window,
the default is not set and nothing shows in the console.
It appears that the awakeFromInsertion() method isn't even being
invoked. But since I'm simply making a modification to a D2JC
application, I don't know everything that is going on behind the
scenes to trigger a new instance and therefor what might be going
wrong prior to this point.
Anybody have any ideas?
Dave
On May 19, 2006, at 12:12 AM, Chuck Hill wrote:
When you create a new Routing, is it getting inserted into an EC?
This method is not called until that is done.
On May 18, 2006, at 3:40 PM, David Avendasora wrote:
Okay, Here's my code:
public void awakeFromInsertion (EOEditingContext ec) {
super.awakeFromInsertion(ec);
EOFetchSpecification fs =
EOFetchSpecification.fetchSpecificationNamed("Task","RoutingType");
NSArray routingTypes = ec.objectsWithFetchSpecification(fs);
System.out.println(routingTypes.objectAtIndex(0).toString());
setRoutingType((EOGenericRecord)routingTypes.objectAtIndex(0));
}
It's not working at all. No errors at least, but it doesn't appear
to be being called either because when I create a new Routing in
the UI, it doesn't set the default value, and I don't get the
message printed out in the console either.
It's nearly midnight here. I'm going to bed. Maybe I'll have
inspiration in the morning.
Dave
On May 18, 2006, at 10:55 PM, Chuck Hill wrote:
IIRC, EOAccess is not available client side.
On May 18, 2006, at 2:49 PM, David Avendasora wrote:
Hmmm...
When I try to import the eoaccess package, I get this error at
compile-time:
src/com/bestmaid/erp/client/Routing.java:10: package
com.webobjects.eoaccess does not exist
import com.webobjects.eoaccess.*;
The JavaEOAccess.framework is part of the project and part of
the Web Server target, as is the Routing.java file.
I don't understand why it sees the other packages (eocontrol,
foudation) but not eoaccess.
Any ideas?
Dave
On May 18, 2006, at 6:25 PM, Ken Anderson wrote:
David,
Besides calling the set method in awakeFromInsertion(), I can't
imagine what else there is to do. Of course, you need to get
the EO in the correct editing context. Since the EC is passed
into the awakeFromInsertion() method, you could:
public void awakeFromInsertion(EOEditingContext ec) {
MyObject obj = EOUtilities.objectMatchingKeyandValue(ec,
"ENTITY", "KEY", "VALUE");
setRelObj(obj);
}
I've never done Java client, but I would assume this will work...
Ken
On May 18, 2006, at 1:12 PM, David Avendasora wrote:
Hi all,
I know this has to be an incredibly simple thing to do, but I
can't seem to figure out how.
All I want to do is defaults so that when an object is
instantiated, it automatically has some of it's relationships
defined. It is VERY easy to do this for an attribute, but I
just can't get it to work for a relationship and I can't find
in the documentation how to do it.
I know the code belongs in the awakeFromInsertion() method.
Can anyone give me a pointer to where in the documentation to
look for this, or better yet a simple code fragment?
BTW, this is for a Java Client application, but I don't think
that matters, right?
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
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:
40global-village.net
This email sent to email@hidden
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems. http://www.global-village.net/products/
practical_webobjects
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/
practical_webobjects
_______________________________________________
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