Hello there,
I am a lot luckier in VW 7.5 with key/keyRef object bindings. BUT: it seems that if I register a BindingManager and use it for unmarshaling, I get several instances of the referenced objects, all with the same contents, but being not identical ( == is false)! It seems an object exists in as many copies as * times it is being found in the xml file (in my case only once) * times a keyRef attribute refers to an its id. So if I have a Customer object that is marshaled once in a collection, having an custNo="123", and three Orders in the same file referencing custNo="123", I will end up having 4 Instances of Customers, each having the same data in their instance variables, but each being an individual instance. What am I doing wrong? I'm using a bare VWNC download CD from April 2007... Regards Joachim |
Hi all,
I want to get data out of a DataSetView in tab delimited string form. I'm sure someone must have done this already? Thanks for any help! cheers, Kimberly This email and all content are subject to the following disclaimer: http://content.momentum.co.za/content/legal/disclaimer_email.htm |
Here is not very elegant, but working method to do it. I am using it to
export data from the data set where all of the fields are read only. yOU probably have to modify it a bit for the case when some of them are editors... copyTableOn: aStream "will copy entire table as CSV" | sel dataSet columnModel | dataSet := (builder componentAt: #Dataset1) widget. dataSet columnDescriptors do: [:ea | aStream nextPutAll: ea labelSpec label asString; tab]. aStream skip: -1. aStream cr. dataSet model value do: [:aRow | dataSet columnDescriptors do: [:aDescriptor | columnModel := aDescriptor editModel. sel := columnModel valueUsingSubject: aRow value. sel isNil ifTrue: [sel := String new]. aStream nextPutAll: ((sel respondsTo: #asString) ifTrue: [sel asString] ifFalse: [sel printString]). aStream tab]. aStream skip: -1. aStream cr]. aStream skip: -1 "@__markp 09/26/2006 10:58:30 am" Anderson, Kimberly wrote: > Hi all, > > I want to get data out of a DataSetView in tab delimited string form. > I'm sure someone must have done this already? > > Thanks for any help! > > cheers, > Kimberly > > This email and all content are subject to the following disclaimer: > > http://content.momentum.co.za/content/legal/disclaimer_email.htm > > |
In reply to this post by Anderson, Kimberly
Well, presumably the data is in a List (or OrderedCollection) object that
sits behind the DataSet. What you want to do is something like this: (assuming that stream points to a file) myList do: [:each | each writeSelfTabDelimitedOn: stream. stream cr]. Where the method #writeSelfTabDelimitedOn: is implemented in the domain object, and simply dumps each instance variable to the stream, followed by a tab. something like: writeSelfTabDelimitedOn: stream stream nextPutAll: self instVarOneAccessorHere printString; tab. stream nextPutAll: self instVarTwoAccessorHere printString; tab. ... ----- Original Message ----- From: "Anderson, Kimberly" <[hidden email]> To: <[hidden email]> Sent: Thursday, July 26, 2007 11:49 AM Subject: Getting data from DataSetView > Hi all, > > I want to get data out of a DataSetView in tab delimited string form. > I'm sure someone must have done this already? > > Thanks for any help! > > cheers, > Kimberly > > This email and all content are subject to the following disclaimer: > > http://content.momentum.co.za/content/legal/disclaimer_email.htm > > > |
In reply to this post by jtuchel
In the attached sample the retuned objects are identical.
Can you create a small test case and send it to me? Tamara Kogan Smalltalk development, Cincom Systems > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] > Sent: Thursday, July 26, 2007 10:52 AM > To: [hidden email] > Subject: [XML::keyRef] Object Identity seems to not be maintained > > Hello there, > > I am a lot luckier in VW 7.5 with key/keyRef object bindings. > > BUT: it seems that if I register a BindingManager and use it for > unmarshaling, I get several instances of the referenced objects, all > the same contents, but being not identical ( == is false)! > > It seems an object exists in as many copies as > * times it is being found in the xml file (in my case only once) > * times a keyRef attribute refers to an its id. > > So if I have a Customer object that is marshaled once in a collection, > having an custNo="123", and three Orders in the same file referencing > custNo="123", I will end up having 4 Instances of Customers, each > the same data in their instance variables, but each being an individual > instance. > > What am I doing wrong? > > I'm using a bare VWNC download CD from April 2007... > > Regards > > Joachim Key KeyRef Mapping.zip (1K) Download Attachment |
Tamara,
thanks for the demo code. I just tried to hack a testcase and cant't reproduce the problem. Maybe I do make a mistake that is not related to the binding specification, but to my handling of the binding manager... In my new testcase (which does not produce too many instances) I do not reuse the bindingManager, but rebuild it for marshalling and unmarshalling. This testcase writes an xml file and quits. Marshalling is then done with a newly created binding manager. In the testcase I used for my project's code I use the same binding manager for unmarshalling to a stream and marshalling back to a new variabe afterwards. Maybe I have some problems with the binding managers' cache handling? Did I overlook some cleanup I have to do after or before every marshalling/unmarshalling? I will now change my "real" testcase so that it builds up the binding manager each time it marshals / unmarshals, and see if there is any difference. I'll report as soon as possible. cu Joachim |
In reply to this post by Anderson, Kimberly
Brilliant! Thanks Mark! I will try this!!
cheers, Kimberly -----Original Message----- From: Mark Pirogovsky [mailto:[hidden email]] Sent: 26 July 2007 18:06 To: Anderson, Kimberly Cc: [hidden email] Subject: Re: Getting data from DataSetView Here is not very elegant, but working method to do it. I am using it to export data from the data set where all of the fields are read only. yOU probably have to modify it a bit for the case when some of them are editors... copyTableOn: aStream "will copy entire table as CSV" | sel dataSet columnModel | dataSet := (builder componentAt: #Dataset1) widget. dataSet columnDescriptors do: [:ea | aStream nextPutAll: ea labelSpec label asString; tab]. aStream skip: -1. aStream cr. dataSet model value do: [:aRow | dataSet columnDescriptors do: [:aDescriptor | columnModel := aDescriptor editModel. sel := columnModel valueUsingSubject: aRow value. sel isNil ifTrue: [sel := String new]. aStream nextPutAll: ((sel respondsTo: #asString) ifTrue: [sel asString] ifFalse: [sel printString]). aStream tab]. aStream skip: -1. aStream cr]. aStream skip: -1 "@__markp 09/26/2006 10:58:30 am" Anderson, Kimberly wrote: > Hi all, > > I want to get data out of a DataSetView in tab delimited string form. > I'm sure someone must have done this already? > > Thanks for any help! > > cheers, > Kimberly > > This email and all content are subject to the following disclaimer: > > http://content.momentum.co.za/content/legal/disclaimer_email.htm > > |
In reply to this post by jtuchel
Hi again!
it's like I suspected: The multiple instances only show up if I use the same binding manager for marshalling and unmarshalling afterwards. Now that I have a TestCase which builds up a new bindingmanager in its setUp method for marshalling and unmarshalling separately, the problem doesn't show up. cu Joachim |
In reply to this post by Anderson, Kimberly
Kimberly,
Please do not overlook the post from James Robertson in the thread. My method would allow you to WYSIWYG export of data from the data set. Which is sufficient for many uses cases. He is talking more along the line of getting to the underlying collection which feeds the dataset view. His approach gives you more options and controls on what and how things might get exported... --Mark Anderson, Kimberly wrote: > Brilliant! Thanks Mark! I will try this!! > > cheers, > Kimberly > > > -----Original Message----- > From: Mark Pirogovsky [mailto:[hidden email]] > Sent: 26 July 2007 18:06 > To: Anderson, Kimberly > Cc: [hidden email] > Subject: Re: Getting data from DataSetView > > > Here is not very elegant, but working method to do it. I am using it to > export data from the data set where all of the fields are read only. > yOU probably have to modify it a bit for the case when some of them > are editors... > > > copyTableOn: aStream > "will copy entire table as CSV" > > > | sel dataSet columnModel | > dataSet := (builder componentAt: #Dataset1) widget. > dataSet columnDescriptors do: > [:ea | > aStream > nextPutAll: ea labelSpec label asString; > tab]. > aStream skip: -1. > aStream cr. > dataSet model value do: > [:aRow | > dataSet columnDescriptors do: > [:aDescriptor | > columnModel := aDescriptor editModel. > sel := columnModel valueUsingSubject: aRow value. > sel isNil ifTrue: [sel := String new]. > aStream nextPutAll: ((sel respondsTo: #asString) > ifTrue: [sel asString] > ifFalse: [sel printString]). > aStream tab]. > aStream skip: -1. > aStream cr]. > aStream skip: -1 > > "@__markp 09/26/2006 10:58:30 am" > > Anderson, Kimberly wrote: > > >>Hi all, >> >>I want to get data out of a DataSetView in tab delimited string form. >>I'm sure someone must have done this already? >> >>Thanks for any help! >> >>cheers, >>Kimberly >> >>This email and all content are subject to the following disclaimer: >> >>http://content.momentum.co.za/content/legal/disclaimer_email.htm >> >> > > > |
Free forum by Nabble | Edit this page |