• 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: awakeFromInsertion on the client side in a D2J App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awakeFromInsertion on the client side in a D2J App


  • Subject: Re: awakeFromInsertion on the client side in a D2J App
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 15 Apr 2005 10:15:29 -0700


On Apr 14, 2005, at 2:55 PM, email@hidden wrote:

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 find this description a little confusing. From the code below it appears that one Employee can have many EmployeeOrders. Each will need its own PK. How are you intending that the propogate primary key work? That is usually more suited to owned, to-one relationships.



 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);
Does it freeze, or raise an exception? I would expect that employee may == null in the above line. This does not seem like suitable code for awakeFromInsertion. I would have this in some method, say createNewOrder() on Employee. That method would create the order, attach it, and set defaults.


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.


They keys are only propogated when the objects are saved. Not all relationships will be set after super.awakeFromInsertion, only the ones marked Owns Destination and their reverse. And that is not something I think you want to use in this case.


Chuck


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:
village.net


This email sent to email@hidden

--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development 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


References: 
 >RE: awakeFromInsertion on the client side in a D2J App (From: email@hidden)

  • Prev by Date: RE: Tiger, EOF & CoreData
  • Next by Date: Re: counting the bytes
  • Previous by thread: RE: awakeFromInsertion on the client side in a D2J App
  • Next by thread: Tiger, EOF & CoreData
  • Index(es):
    • Date
    • Thread