Re: ClassCastException???
Re: ClassCastException???
- Subject: Re: ClassCastException???
- From: Johann Werner <email@hidden>
- Date: Thu, 2 Oct 2008 18:27:40 +0200
Hi Awbrey,
I suppose the Listing, Basic and Specific are all EOs? Then you can't
create new objects of them by just instantiating them the java way.
You have to tell WO to create them by using
EOUtilities.createAndInsertInstance(EOEditingContext ec, String
entityName)
This inserts a new object of entityName into a specific editing
context which you can save at a later stage.
jw
Am 02.10.2008 um 18:04 schrieb Awbrey Hughlett:
I am getting a classCastException from this when I invoke
saveChanges(). What am I doing wrong again?
public class DataEntry extends WOComponent {
private Listing listing = new Listing();
private Basic basic = new Basic();
private Specific specific = new Specific();
private ERXEC ec = new ERXEC();
public Basic aBasic = new Basic();
public Specific aSpecific = new Specific();
public DataEntry(WOContext context) {
super(context);
ec.insertObject(listing);
ec.insertObject(basic);
ec.insertObject(specific);
}
public ERXEC editingContext() {
return ec;
}
public Listing listing() {
if (listing == null) {
ec.revert();
listing = (Listing)EOUtilities.createAndInsertInstance(ec,
"Listing");
}
return listing;
}
public NSArray allSpecificTypes() {
return EOUtilities.objectsForEntityNamed(ec, "Specific");
}
public NSArray allBasicTypes() {
return EOUtilities.objectsForEntityNamed(ec, "Basic");
}
public WOComponent saveChanges() {
listing().setLastModified(new NSTimestamp());
listing().setUserId(1);
listing().addObjectToPropertyWithKey(aSpecific, "specific");
listing().addObjectToPropertyWithKey(aBasic, "basics");
ec.saveChanges();
setBasic(null);
setSpecific(null);
setListing(null);
return context().page();
}
public void setListing(Listing newListing) {
listing = newListing;
}
public Basic basicListing() {
return basic;
}
public Specific specificListing() {
return specific;
}
public void setBasic(Basic newBasic) {
basic = newBasic;
}
public void setSpecific(Specific newSpecific) {
specific = newSpecific;
}
}
this is the first part of the stack trace for this error:
java.lang.ClassCastException: com.webobjects.foundation.NSMutableArray
_Listing.java
231
specific
com.findthemlistings.eo
NativeMethodAccessorImpl.java
NA
invoke0
sun.reflect
NativeMethodAccessorImpl.java
39
invoke
sun.reflect
DelegatingMethodAccessorImpl.java
25
invoke
sun.reflect
Method.java
585
invoke
java.lang.reflect
NSKeyValueCoding.java
684
methodValue
com.webobjects.foundation
NSKeyValueCoding.java
1160
valueInObject
com.webobjects.foundation
EOCustomObject.java
1559
valueForKey
com.webobjects.eocontrol
EOCustomObject.java
774
eoDescription
com.webobjects.eocontrol
EOCustomObject.java
239
toString
com.webobjects.eocontrol
NSArray.java
920
toString
com.webobjects.foundation
String.java
2615
valueOf
java.lang
StringBuilder.java
116
append
java.lang
_______________________________________________
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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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