I'm not sure how much it matters in this case, but it might be a good idea to call the super implementation inside awakeFromInsertion like so:

- (void) awakeFromInsertion(EOEditingContext ec) {
super.awakeFromInsertion(ec);
this.setBriefDatum(new NSTimestamp());
}

On Aug 30, 2006, at 8:14 AM, Ken Anderson wrote:

Mike,

If you want to initialize a field to be a certain value, you should use the awakeAfterInsertion(EOEditingContext ec) method.  Implement it like this:

- (void) awakeFromInsertion(EOEditingContext ec) {
this.setBriefDatum(new NSTimestamp());
}

Modifying a set method to not have the correct signature is a huge problem for KeyValueCoding (and probably many other things!)

Ken

On Aug 30, 2006, at 8:04 AM, Mike Bobkiewicz wrote:

Hi,
I´m in trouble with NSTimestamp. I´m using this to store the durrent
date to a database. While there is no need to edit this date I´ve
altered the acceorclass for the database object like that:

public void setBriefDatum()
    NSTimeStamp value = new NSTimeStamp();
    takeStoredValueForKey(value, "briefDatum");
}

When you hit the new button in my form a new object "briefe" is
initialisied ,which includes the datafield "briefDatum", I then call the
"setBriefDatum" method and the date shows up in the connected Formfield.
You can enter your data and hit the save button. After that an exception
occured. Funny thing, it occures when all my code is finished and the
page is displayed again. Data is saved to database, all aftersave work
of my code is executed, don´t know where error might be.

The error message:

 [2006-08-30 13:20:18 CEST] <WorkerThread6>
<com.webobjects.appserver._private.WOComponentRequestHandler>: Exception
occurred while handling request:
java.lang.ClassCastException
[2006-08-30 13:20:18 CEST] <WorkerThread6> java.lang.ClassCastException
at briefe.briefDatum(briefe.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at KeyValueCodingProtectedAccessor.methodValue
(KeyValueCodingProtectedAccessor.java:54)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.valueInObject(NSKeyValueCoding.java:1160)
at com.webobjects.eocontrol.EOCustomObject.valueForKey
(EOCustomObject.java:1559)
at com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey
(NSKeyValueCoding.java:498)
at com.webobjects.foundation.NSKeyValueCodingAdditions
$DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java:212)
at com.webobjects.eocontrol.EOCustomObject.valueForKeyPath
(EOCustomObject.java:1675)
at com.webobjects.foundation.NSKeyValueCodingAdditions
$Utility.valueForKeyPath(NSKeyValueCodingAdditions.java:149)
at com.webobjects.foundation.NSKeyValueCodingAdditions
$DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java:217)
at com.webobjects.appserver.WOComponent.valueForKeyPath
(WOComponent.java:1600)
at com.webobjects.appserver._private
.WOKeyValueAssociation.valueInComponent(WOKeyValueAssociation.java:46)
at com.webobjects.appserver._private
.WOTextField._appendValueAttributeToResponse(WOTextField.java:91)
at com.webobjects.appserver._private.WOInput.appendAttributesToResponse
(WOInput.java:140)
at com.webobjects.appserver._private
.WOHTMLDynamicElement._appendOpenTagToResponse(WOHTMLDynamicElement.java:395)
at com.webobjects.appserver._private
.WOHTMLDynamicElement.appendToResponse(WOHTMLDynamicElement.java:420)
at com.webobjects.appserver._private
.WODynamicGroup.appendChildrenToResponse(WODynamicGroup.java:121)
at com.webobjects.appserver._private.WOForm.appendChildrenToResponse
(WOForm.java:124)
at com.webobjects.appserver._private
.WOHTMLDynamicElement.appendToResponse(WOHTMLDynamicElement.java:424)
at com.webobjects.appserver._private.WOForm.appendToResponse(WOForm.java:118)
at com.webobjects.appserver._private
.WODynamicGroup.appendChildrenToResponse(WODynamicGroup.java:121)
at com.webobjects.appserver._private.WODynamicGroup.appendToResponse
(WODynamicGroup.java:130)
at com.webobjects.appserver.WOComponent.appendToResponse
(WOComponent.java:992)
at com.webobjects.appserver.WOSession.appendToResponse(WOSession.java:1200)
at com.webobjects.appserver.WOApplication.appendToResponse
(WOApplication.java:1418)
at com.webobjects.appserver._private
.WOComponentRequestHandler._dispatchWithPreparedPage
(WOComponentRequestHandler.java:230)
at com.webobjects.appserver._private
.WOComponentRequestHandler._dispatchWithPreparedSession
(WOComponentRequestHandler.java:287)
at com.webobjects.appserver._private
.WOComponentRequestHandler._dispatchWithPreparedApplication
(WOComponentRequestHandler.java:322)
at com.webobjects.appserver._private
.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:358)
at com.webobjects.appserver._private
.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:432)
at com.webobjects.appserver.WOApplication.dispatchRequest
(WOApplication.java:1306)
at com.webobjects.appserver._private.WOWorkerThread.runOnce
(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run
(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:552)

Regards,

  Mike

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

--
Robert Walker



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to