Re: setting values
Re: setting values
- Subject: Re: setting values
- From: Art Isbell <email@hidden>
- Date: Wed, 19 Feb 2003 14:01:50 -1000
On Wednesday, February 19, 2003, at 12:40 PM, A. Uchida wrote:
MacOS 10.1.5 & WO5.0
If possible, upgrade to WO 5.1.3 for the most stable WO version that
runs under OS X 10.1.
What I am trying to do in WO application is
1. Create a new record in an entityA using display group insert().
2. Save the new record in the entityA using saveChanges().
3. Create a new record in an entityB using insert().
4. set a value of an attribute of entityA to an attribute of the
entityB
5. saveChanges() of entityB.
I want to do the process 2 to 4 by an action on a WO component.
What I did to set the value was to add
entityB.aData = entityA.aData;
in the action method in the java file.
Both entityA and B was produced as a key using the entities.
And it doesn't allow me to finish the build.
I think I had to use a method, something like "takeValueForKey".
But I don't know how to use it.
Question1 : what method can be used to set a value of an entity to a
field
of the other entity?
EOF (Enterprise Objects Framework) is used by WO for database
manipulation. An entity represents a database table in EOF. Each row
in the table is represented by an object in EOF. Each object is an
instance of a Java class associated with an entity in your eomodel. By
default, the class is EOGenericRecord. If you need to implement custom
business logic, you must associate a custom Java class with each entity
in your eomodel and generate a Java class file for each custom Java
class.
NSKeyValueCoding methods may be used to set (takeValueForKey()) and
get (valueForKey()) values regardless of whether you use
EOGenericRecord or a custom Java class
(http://developer.apple.com/techpubs/webobjects/Reference/API/com/
webobjects/foundation/NSKeyValueCoding.html). Assuming aData is an
attribute and not a relationship (relationship values can be set and
gotten as well but using different methods):
entityB.takeValueForKey(entityA.valueForKey("aData"), "aData");
But the Java compiler is unable to check whether the string key
argument of these methods, "aData", is valid, so the app may compile
but throw an exception at runtime. To avoid this, use custom Java
classes and their custom set and get methods:
entityB.setAData(entityA.aData());
Question 2 : I am learning WO by myself and had read some books for WO
but
when I get lost like this case, what kind of documents, do you think,
are usefull?
I checked the documents of the WO: EOControl, Java reference for Java
etc.
But I don't think it is useful.
I hope some other new WO users will respond.
I think you must have a basic understanding of Java first. You don't
need to know all of Java's features or most of the Java library API's
for WO, but you should be able to read and understand Java code as well
as write Java code at the level provided in
/Developer/Examples/JavaWebObjects. There are many Java language books
that can provide this level of Java skill. You should also be familiar
with the Java API's in at least the java.lang, java.text, and java.util
packages documented at http://java.sun.com/j2se/1.3/docs/api/.
Then you need to become familiar with WO itself. You should become
familiar with the API's in the com.webobjects.appserver,
com.webobjects.eoaccess, com.webobjects.eocontrol, and
com.webobjects.foundation packages documented at
http://developer.apple.com/techpubs/webobjects/WebObjects_5.1/
Reference/Javadoc/index.html.
http://developer.apple.com/techpubs/webobjects/WebObjects_5.1/
webobjects.html provides links to various documentation and tutorials
that you should be familiar with including the development tools and
environment.
There's much to learn, but you don't have to learn everything to
become productive.
Art
http://homepage.mac.com/aisbell/
_______________________________________________
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.