Re: Debuging WOManyToManyRelationship
Re: Debuging WOManyToManyRelationship
- Subject: Re: Debuging WOManyToManyRelationship
- From: Dev WO <email@hidden>
- Date: Fri, 22 Jul 2005 19:02:40 +0200
After digging for hours, I have found something very strange:
If I remove the WOToMany, I can add object to the database, then I
put back the WOToMany, then edit a previous object (already in the
DB) then the WOToMany works, everything gets written in the join
table, no problem...
So I could save all products first then apply them to the categories
(WOToMany), but in fact I can't do that as I got the crash even if I
don't select anything in the WOToMany browser...
So I understand this seems to be related to the object not inside an
EC when it is created. So I tried:
---
public WOComponent addOrUpdateProductGeneric()
{
if (!productGenericList.containsObject(productGeneric))
{
ec.insertObject(productGeneric);
productGenericList.addObject(productGeneric);
awakeFromInsertionProductGeneric(ec); // this is to set
the date posted
}
else
{
awakeFromInsertionProductGeneric(ec); // this is to set
the date last updated
}
productGeneric = new ProductGeneric();
ec.saveChanges();
return context().page();
---
But it leads to the same crash...
any ideas?
Thanks
Le 22 juil. 05 à 13:01, Dev WO a écrit :
I've been setting up a form with a WOManyToMany relationship, I
tried it and it worked, the correct values were written in the
database in the join-table.
I still worked on this project, though I don't remember exactly
what I've done...
I had to left this for a couple days and when back on it, I've seen
that saving would lead to an exception like the one Amedeo Mantica
got on may 19th 2005:
----
[2005-07-22 10:24:51 CEST] <WorkerThread7>
java.lang.NullPointerException
at
com.webobjects.woextensions.WOToManyRelationship.updateSourceObject
(WOToManyRelationship.java:348)
at
com.webobjects.woextensions.WOToManyRelationship.setSelections
(WOToManyRelationship.java:421)
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 com.webobjects.foundation.NSKeyValueCoding$1.setMethodValue
(NSKeyValueCoding.java:688)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.setValueInObject(NSKeyValueCoding.java:1175)
at com.webobjects.foundation.NSKeyValueCoding
$DefaultImplementation.takeValueForKey(NSKeyValueCoding.java:1293)
at com.webobjects.appserver.WOComponent.takeValueForKey
(WOComponent.java:1550)
at com.webobjects.foundation.NSKeyValueCoding
$Utility.takeValueForKey(NSKeyValueCoding.java:519)
at com.webobjects.foundation.NSValidation
$DefaultImplementation.validateTakeValueForKeyPath
(NSValidation.java:733)
at
com.webobjects.appserver.WOComponent.validateTakeValueForKeyPath
(WOComponent.java:1273)
at
com.webobjects.appserver._private.WOKeyValueAssociation.setValue
(WOKeyValueAssociation.java:71)
at
com.webobjects.appserver._private.WOBrowser._fastTakeValuesFromRequest
(WOBrowser.java:153)
at
com.webobjects.appserver._private.WOBrowser.takeValuesFromRequest
(WOBrowser.java:168)
at
com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFro
mRequest(WODynamicGroup.java:81)
at
com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest
(WODynamicGroup.java:89)
at
com.webobjects.appserver._private.WOConditional.takeValuesFromRequest(
WOConditional.java:41)
at
com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFro
mRequest(WODynamicGroup.java:81)
at
com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest
(WODynamicGroup.ja
----
But has the solution was to change the workflow, it doesn't help me
fix my problem...
So let's try to explain it correctly:
-I've got a regular form, and without the WOToMany it works like a
charm.
-When adding the WOToMany, the display is also correct, so the
bindings should be ok (I've rechecked numerous time, and if I made
a mistake I couldn't get a correct display), here's the .woa
declaration:
----
ToManyRelationship: WOToManyRelationship {
relationshipKey = "productCategorys";
sourceObject = productGeneric;
sourceEntityName = "ProductGeneric";
uiStyle = "browser";
destinationDisplayKey = "name";
}
----
-When submitting the form (which also save ec), I got the
crash...Here's my save method:
----
public WOComponent addOrUpdateProductGeneric()
{
if (!productGenericList.containsObject(productGeneric))
{
productGenericList.addObject(productGeneric);
ec.insertObject(productGeneric);
awakeFromInsertionProductGeneric(ec); // this is to set
the date posted
}
else
{
awakeFromInsertionProductGeneric(ec); // this is to set
the date last updated
}
productGeneric = new ProductGeneric();
ec.saveChanges();
return context().page();
}
----
I really don't know how to track what's happening...
If anyone could come up with a clue, that would be a real savior.
Thanks
Xavier
PS: As mentioned by Chuck in an answer to Amedeo's problem:
----
This is where the execption happens, last line:
public void updateSourceObject(NSArray newValues) {
// add new values to relationship, remove old values
Object aSourceObject = _localSourceObject();
boolean isDictionary = (aSourceObject instanceof
NSMutableDictionary);
NSMutableDictionary _dictionary = (isDictionary) ?
(NSMutableDictionary) aSourceObject : null;
EOEnterpriseObject _eo = (!isDictionary) ?
(EOEnterpriseObject) aSourceObject : null;
String masterKey = _localRelationshipKey();
NSMutableArray currentValues = (NSMutableArray)
NSKeyValueCoding.Utility.valueForKey(aSourceObject, masterKey);
int count = currentValues.count();
Thus, NSKeyValueCoding.Utility.valueForKey(aSourceObject,
masterKey) returns null. In other words, sourceObject.valueForKey
(masterKey) returns null. Check the spelling of your bindings. It
looks like you have misspelled the tomany relation.
Chuck
----
I've checked all bindings, and I cannot find a mistake. In addition
to that, Could I get the WOToMany to display if there were an error?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anazys.com
This email sent to email@hidden
_______________________________________________
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