RE: awakeFromInsertion on the client side in a D2J App
RE: awakeFromInsertion on the client side in a D2J App
- Subject: RE: awakeFromInsertion on the client side in a D2J App
- From: email@hidden
- Date: Thu, 14 Apr 2005 17:55:20 -0400
Hi all,
I am having a similar problem with D2JC and awakeFromInsertion... I am newbie to WO and JavaClient. I am looking for some assistance.
I have two entities, Employee and EmployeeOrder. Employee is a parent to
EmployeeOrder and I have "Propagate Primary Key" checked off from the Employee
to the EmployeeOrder relationship in EOModeler. I generated client side Java class files, put
them to the Webserver target and have them packaged in "logic.client".
When I construct the D2JC application I can navigate, insert and delete both
Employees and their respective orders (EmployeeOrders). I am now attempting to
create some default values on the client side of EmployeeOrder.java.
I use the awakeFromInsertion method when a new EmployeeOrder is created and
can default some values. However, if I attempt to access a method from the parent
in this relationship, the Java Client freezes.
This works...
public void awakeFromInsertion (EOEditingContext context) {
super.awakeFromInsertion(context);
takeValueForKey(new Integer(102),"orderNumber");
}
This does not work and freezes as soon as I call the parent's method.
public void awakeFromInsertion (EOEditingContext context) {
super.awakeFromInsertion(context);
logic.client.Employee employee = (logic.client.Employee) employee();
Number nextOrderNumber = new Integer(employee.getMaxEmployeeOrderNumber().intValue() + 1);
takeValueForKey(nextOrderNumber,"orderNumber");
}
If the primary key (Employee) is propagated with normal inserts, it seems like I
should be able to access the methods in the Employee class (such as
getMaxEmployeeOrderNumber). It seems as if the object (EmployeeOrder) does
not have all of its relations in the awakeFromInsertion method, even after super.awakeFromInsertion is called.
I know there are probably other ways around this, but want to know if there is away
to get this to work in the awakeFromInsertion method on the client side? (I also
realize that this abstracted example may not make design sense ... I just would like
to understand the processes as this is just an example to help me learn).
I see the last thread something that looked promising. But I cannot see the method setRelationship() in any of the APIs, and more fundamentally, I cannot seem to access the parent at all from awakeFromInsertion.
Any help would be appreciated
Thanks,
Kevin
From: <email@hidden>
Date: Thu, 14 Apr 2005 17:32:07 +0200
Thread-topic: awakeFromInsertion on the client side in a D2J App
If your default values depend on the parent you may want to set them in the appropriate setter method:
public void setParent(Parent parent)
{
if (parent() == null)
{
setRelationship(parent.relationship()):
}
super.setParent(parent);
}
Pierre
_______________________________________________
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