Re: Object property initialization problem
Re: Object property initialization problem
- Subject: Re: Object property initialization problem
- From: Arturo Perez <email@hidden>
- Date: Tue, 20 Apr 2004 18:13:38 -0400
Randall Perry wrote:
Got a Direct Action that calls a component page, ResultPage, passing it a
EOGenericRecord object, CustView, that's populated with data.
Is CustView a class or an instance? BTW, what platform are you
developing on? How is that object being passed to/through the DA?
Am able to access properties of the CustView object in the component (via
.wod file). But need to access a property of the object in a method in
ResultPage.java.
Well, you could do it the same way WO does (the way the component does):
(whatever your EOGenericRecord is called).valueForKeyPath("userName");
So, tried to access it and got 'Cannot resolve symbol' error. Thought ok, so
I need to create a dummy instance of the class object because the compiler
doesn't know it's going to be set by the Direct Action, so I created it.
public CustView custInfo = new CustView();
String custDir = "/Users" + custInfo.userName;
That's not going to work unless the userName property is a public ivar.
Bad practice to make it a public ivar but you're welcome to do
whatever you like :-)
Then I got the same error trying to access the object property 'userName'.
So tried initializing userName to an empty string but couldn't find a way to
do it without error:
public CustView custInfo = new CustView();
custInfo.setUserName("");
2nd line above generates error "<identifier> expected"
Sounds like your class doesn't have the methods you think it has.
CustView is a subclass of EOGenericRecord? Then you can use
valueForKey/takeValueForKey.
-arturo
_______________________________________________
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.