• 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: Setting a Default toOne Relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a Default toOne Relationship


  • Subject: Re: Setting a Default toOne Relationship
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 25 May 2006 09:21:23 -0700


On May 25, 2006, at 2:53 AM, David Avendasora wrote:

I'm in the middle of moving from the UK to the US and I just transitioned my development environment from my PowerMac to my iBook and things seem to have magically started working. Somewhat. I tried setting simple text values on a couple attributes on both the server-side and client-side classes. It works just fine on the client side, but not at all on the server side. It appears that the server-side code is never being called.

That is what I would expect. awakeFromInsertion should be processed client side.

When I try to use a fetch specification to retrieve the object that I want to setup the relationship to, I get:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Array is empty
at com.webobjects.foundation.NSArray.objectAtIndex(NSArray.java:510)
at com.bestmaid.erp.client.Bill_Of_Material.awakeFromInsertion (Bill_Of_Material.java:25)


The line it is complaining about is designated below:

	public void awakeFromInsertion (EOEditingContext ec) {
		super.awakeFromInsertion(ec);
		EOFetchSpecification fs =
			EOFetchSpecification.fetchSpecificationNamed("BillOfMaterial",
				"RoutingType");
		NSArray routingType = (NSArray)ec.objectsWithFetchSpecification(fs);
--->		System.out.println(routingType.objectAtIndex(0).toString());
		//setRoutingType((EOGenericRecord)routingType.objectAtIndex(0));

		if (routingDescription() == null) {
			setRoutingDescription("Routing Description");
		}

	}

The setRoutingDescription("Routing Description") works exactly as the documentation describes.

Is there some problem with the way I'm building the NSArray? I'm really only expecting one value, not an array, but I can't see how to just get one record.

Perhaps, I don't know what your fetch spec looks like. Have you tried logging the SQL on the server to see what is being generated? It is also possible that fetching in awakeFromInsertion on the client fails for some reason.


When I use DBEdit to execute the fetch specification, it returns the record from the DB that I'd expect. I'm not sure why my Java Code won't.

The first thing is to check and see if it is being run on the server.

Chuck


On May 19, 2006, at 4:11 PM, Chuck Hill wrote:

According to the WebObjects Java Client Programming Guide (http:// developer.apple.com/documentation/WebObjects/DesktopApplications/ WODesktopApps.pdf), Chapter 6, the section on specifying initial values (page 123) if you add setters in the awakeFromInsertion() method, these values will show up immediately.

...
Build and run the application and create a new student record. You’ll notice that some of the fields are populated in the new record as shown in Figure 6-11.

Have you tried this example? Does it work?



--
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
  • Follow-Ups:
    • Re: Setting a Default toOne Relationship
      • From: David Avendasora <email@hidden>
References: 
 >Re: Setting a Default toOne Relationship (From: David Avendasora <email@hidden>)
 >Re: Setting a Default toOne Relationship (From: Chuck Hill <email@hidden>)
 >Re: Setting a Default toOne Relationship (From: David Avendasora <email@hidden>)

  • Prev by Date: Re: Really weird NOSuchMethodException editingContextShouldFetchObjects on class:Session
  • Next by Date: Re: Really weird NOSuchMethodException editingContextShouldFetchObjects on class:Session
  • Previous by thread: Re: Setting a Default toOne Relationship
  • Next by thread: Re: Setting a Default toOne Relationship
  • Index(es):
    • Date
    • Thread