Hello all,
I am currently getting my self into a bit of a mess with regards to managing the components of my application. I am finding that the application enters a circular reference when I have two components, that reference each other in #children. An example being a crumb trail (e.g. anchors for "Home >> Stage 1 >> Stage 2 >> etc.") when the user clicks onto Stage 2, but decides to make a change on stage 1 and clicks the "back button", they will receive a "Component not registered for Callback" error, unless I have Stage2>>>#children return a reference to Stage 1. This is causing two problems: 1. How would Stage2 component maintain a reference to Stage 1? 2. How can I provide that reference in Stage2>>>#children without entering a circular reference, because Stage2 must be referenced by Stage1>>>#children? Apologies for the poor explanation, it is a difficult one for me to explain. Many thanks, John www.pinesoft.co.uk Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> 1. How would Stage2 component maintain a reference to Stage 1?
Are you backtracking the state? In Seaside 2.7 by using #registerObjectForBacktracking: and in Seaside 2.8 by implementing #states. > 2. How can I provide that reference in Stage2>>>#children without > entering a circular reference, because Stage2 must be referenced by > Stage1>>>#children? > > Apologies for the poor explanation, it is a difficult one for me to explain. I don't understand your second point. As long as you don't run into infinite loops circular references should be no problem (except for the reusability). Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas Renggli wrote:
>> 1. How would Stage2 component maintain a reference to Stage 1? > > Are you backtracking the state? In Seaside 2.7 by using > #registerObjectForBacktracking: and in Seaside 2.8 by implementing > #states. > No, I am not back tracking the state - I have not got that 'far' yet due to this current problem(s). >> 2. How can I provide that reference in Stage2>>>#children without >> entering a circular reference, because Stage2 must be referenced by >> Stage1>>>#children? >> >> Apologies for the poor explanation, it is a difficult one for me to >> explain. > > I don't understand your second point. As long as you don't run into > infinite loops circular references should be no problem (except for > the reusability). > > Lukas > It is WAComponent>>>childrenDo: which is entering the infinite loop, due to both Stage1 and Stage2 being #children, and both Stage1 and Stage2 returning each other as children. However, if I do not return Stage1 as a child to Stage2, it will generate the callback error if the user clicks back. John. www.pinesoft.co.uk Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by John Thornborrow
On 6 Jun 2007, at 15:21, John Thornborrow wrote: > Hello all, > > I am currently getting my self into a bit of a mess with regards to > managing the components of my application. I am finding that the > application enters a circular reference when I have two components, > that reference each other in #children. I guess I don't really understand. Do you have some code? do you mean that you have something of the form: Component1>>children children := OrderedCollection new. children add: myLocalComponent. children addAll: self component2 children ^children and then something reversed in Component2>>children? Mike _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Michael Roberts wrote:
> > On 6 Jun 2007, at 15:21, John Thornborrow wrote: > >> Hello all, >> >> I am currently getting my self into a bit of a mess with regards to >> managing the components of my application. I am finding that the >> application enters a circular reference when I have two components, >> that reference each other in #children. > I guess I don't really understand. Do you have some code? > > do you mean that you have something of the form: > > Component1>>children > children := OrderedCollection new. > children add: myLocalComponent. > children addAll: self component2 children > ^children > > and then something reversed in Component2>>children? > > Mike > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > > --- Root>>>#children ^Array with: self menuComponent with: self contentComponent Stage1>>>#children ^Array with: Stage2 instance Stage2>>>#children ^Array with: Stage1 instance --- When #childrenDo: loop starts, it will perform a never ending loop. However, if I don't include the above referencing, the user receives an error "Component not registered for callback" My #renderContentOn: method for the two Stage components contains: html anchor callback: [root content: StageX instance]; with: 'click here' Other issue (1. on the list) is the maintenance of the instances, I'm not happy with using singletons as this could (and probably will) generate cross-session changes. John www.pinesoft.co.uk Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> Other issue (1. on the list) is the maintenance of the instances, I'm
> not happy with using singletons as this could (and probably will) > generate cross-session changes. There is something fundamentally wrong with your code. Using singletons certainly won't work. A component encapsulates the state private to a single session, they must not be shared among different sessions. If you could provide a file-out or Monticello package then we could certainly help to solve your problem. With the current information it is rather difficult to help. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas Renggli wrote:
>> Other issue (1. on the list) is the maintenance of the instances, I'm >> not happy with using singletons as this could (and probably will) >> generate cross-session changes. > > There is something fundamentally wrong with your code. Using > singletons certainly won't work. A component encapsulates the state > private to a single session, they must not be shared among different > sessions. > > If you could provide a file-out or Monticello package then we could > certainly help to solve your problem. With the current information it > is rather difficult to help. > > Lukas > something else for now. On the note of singeltons, the reason for this is because if I created a new component object, I would receive the callback error because it is not the same instance as the previous callback state had. Once I get round to generating the file out, hopefully my problem will be more clear. John. www.pinesoft.co.uk Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Attached is an example (MyStuff.st - fileout format)
In order to reproduce the callback error.. 1. Open the page 2. Click the "A Link" url in the top left. 3. Click your back button. 4. Click the "link" in the pink box. Many thanks in advance for any assistance. John. www.pinesoft.co.uk John Thornborrow wrote: > Lukas Renggli wrote: > >>> Other issue (1. on the list) is the maintenance of the instances, I'm >>> not happy with using singletons as this could (and probably will) >>> generate cross-session changes. >>> >> There is something fundamentally wrong with your code. Using >> singletons certainly won't work. A component encapsulates the state >> private to a single session, they must not be shared among different >> sessions. >> >> If you could provide a file-out or Monticello package then we could >> certainly help to solve your problem. With the current information it >> is rather difficult to help. >> >> Lukas >> >> > I shall make a file-out shortly, however I have been asked to work on > something else for now. > > On the note of singeltons, the reason for this is because if I created a > new component object, I would receive the callback error because it is > not the same instance as the previous callback state had. > > Once I get round to generating the file out, hopefully my problem will > be more clear. > > John. > > www.pinesoft.co.uk > > > Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA > > > > This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com > > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > > > WAComponent subclass: #BrokenExample instanceVariableNames: 'menu content registry' classVariableNames: '' poolDictionaries: '' category: 'MyStuff'! !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:32'! children ^Array with: menu with: (registry at: 'content')! ! !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:33'! initialize menu _ MenuContainer new root: self. registry _ (Dictionary new at: 'content' put: (ContentContainer new root: self); yourself)! ! !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:38'! registry ^registry! ! !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:31'! renderContentOn: html html render: menu. html render: (registry at: 'content')! ! !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 10:28'! style ^' div.content, div.menu, div.banner { position: absolute; } div.menu { left: 50px; top: 150px; width: 190px; background-color: #7ff; border: 1px solid #000; } ul.menu { color: #fff; } div.content { left: 290px; top: 100px; height: 400px; width: 250px; background-color: #f7f; border: 1px solid #ccc; } p.content { text-decoration: underline; } div.banner { width: 500px; height: 75px; top: 5px; left: 100px; background-color: #ff7; border: 1px solid #000; } p.banner { size: 20px; color: #000; }'! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! BrokenExample class instanceVariableNames: ''! !BrokenExample class methodsFor: 'as yet unclassified' stamp: 'JMT 6/6/2007 17:44'! canBeRoot ^true! ! WAComponent subclass: #ContentContainer instanceVariableNames: 'uid content root' classVariableNames: '' poolDictionaries: '' category: 'MyStuff'! !ContentContainer methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 12:28'! content: aString content _ aString! ! !ContentContainer methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:35'! renderContentOn: html html div class: 'content'; with: [ html paragraph class: 'content'; with: [html anchor callback: [| a | a _ 'b']; with: 'link']. html paragraph with: (content ifNil: ['foo'])]! ! !ContentContainer methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:33'! root: aComponent root _ aComponent! ! WAComponent subclass: #MenuContainer instanceVariableNames: 'root' classVariableNames: '' poolDictionaries: '' category: 'MyStuff'! !MenuContainer methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:36'! renderContentOn: html html anchor callback: [root registry at: 'content' put: (ContentContainer new content: 'bar'; root: root)]; with: 'A Link'! ! !MenuContainer methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 12:37'! root: aComponent root _ aComponent! ! _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Also note that the same occurs if I remove the registry completely and
use just instance variables of the root object. Thanks again, John www.pinesoft.co.uk John Thornborrow wrote: > Attached is an example (MyStuff.st - fileout format) > > In order to reproduce the callback error.. > > 1. Open the page > 2. Click the "A Link" url in the top left. > 3. Click your back button. > 4. Click the "link" in the pink box. > > Many thanks in advance for any assistance. > > John. > www.pinesoft.co.uk > > > > John Thornborrow wrote: > >> Lukas Renggli wrote: >> >> >>>> Other issue (1. on the list) is the maintenance of the instances, I'm >>>> not happy with using singletons as this could (and probably will) >>>> generate cross-session changes. >>>> >>>> >>> There is something fundamentally wrong with your code. Using >>> singletons certainly won't work. A component encapsulates the state >>> private to a single session, they must not be shared among different >>> sessions. >>> >>> If you could provide a file-out or Monticello package then we could >>> certainly help to solve your problem. With the current information it >>> is rather difficult to help. >>> >>> Lukas >>> >>> >>> >> I shall make a file-out shortly, however I have been asked to work on >> something else for now. >> >> On the note of singeltons, the reason for this is because if I created a >> new component object, I would receive the callback error because it is >> not the same instance as the previous callback state had. >> >> Once I get round to generating the file out, hopefully my problem will >> be more clear. >> >> John. >> >> www.pinesoft.co.uk >> >> >> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA >> >> >> >> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com >> >> _______________________________________________ >> Seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside >> >> >> >> >> >> > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Oh, and just realised I've not informed which version of seaside I
have.. 2.7. Thanks. John www.pinesoft.co.uk John Thornborrow wrote: > Also note that the same occurs if I remove the registry completely and > use just instance variables of the root object. > > Thanks again, > > John > www.pinesoft.co.uk > > John Thornborrow wrote: > >> Attached is an example (MyStuff.st - fileout format) >> >> In order to reproduce the callback error.. >> >> 1. Open the page >> 2. Click the "A Link" url in the top left. >> 3. Click your back button. >> 4. Click the "link" in the pink box. >> >> Many thanks in advance for any assistance. >> >> John. >> www.pinesoft.co.uk >> >> >> >> John Thornborrow wrote: >> >> >>> Lukas Renggli wrote: >>> >>> >>> >>>>> Other issue (1. on the list) is the maintenance of the instances, I'm >>>>> not happy with using singletons as this could (and probably will) >>>>> generate cross-session changes. >>>>> >>>>> >>>>> >>>> There is something fundamentally wrong with your code. Using >>>> singletons certainly won't work. A component encapsulates the state >>>> private to a single session, they must not be shared among different >>>> sessions. >>>> >>>> If you could provide a file-out or Monticello package then we could >>>> certainly help to solve your problem. With the current information it >>>> is rather difficult to help. >>>> >>>> Lukas >>>> >>>> >>>> >>>> >>> I shall make a file-out shortly, however I have been asked to work on >>> something else for now. >>> >>> On the note of singeltons, the reason for this is because if I created a >>> new component object, I would receive the callback error because it is >>> not the same instance as the previous callback state had. >>> >>> Once I get round to generating the file out, hopefully my problem will >>> be more clear. >>> >>> John. >>> >>> www.pinesoft.co.uk >>> >>> >>> Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA >>> >>> >>> >>> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com >>> >>> _______________________________________________ >>> Seaside mailing list >>> [hidden email] >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside >>> >>> >>> >>> >>> >>> >>> >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside >> > > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > > > _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by John Thornborrow
> !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 14:33'!
> initialize > menu _ MenuContainer new root: self. > registry _ (Dictionary new > at: 'content' put: (ContentContainer new root: self); > yourself)! ! 1. Always call super initialize. I know this works in 2.7, but it breaks in 2.8. 2. Register all the objects that reference components that are returned as children for backtracking. This means you need to add the following two lines to the end of your initialize method in 2.7: self session registerObjectForBacktracking: registry; " for the dictionary " registerObjectForBacktracking: self " for the menu " In 2.8 this is simpler, you implement the message #states to answer the objects to be backtracked: states ^ Array with: registry with: self 3. Thanks to your question I found another severe bug in the backtracking of dictionaries (there was a long undiscovered one in Set, but obviously this was not the end). This is fixed and tested against in 2.8. For 2.7 make sure that you have these two methods: Set>>snapshotCopy ^ self copy Dictionary>>restoreFromSnapshot: aDictionary self keys do: [ :key | self removeKey: key ]. aDictionary keysAndValuesDo: [ :key :value | self at: key put: value ] Considering all this makes your example work. Thanks for providing the example that lead to a solution to this bug. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas Renggli wrote:
>> !BrokenExample methodsFor: 'as yet unclassified' stamp: 'JMT 6/7/2007 >> 14:33'! >> initialize >> menu _ MenuContainer new root: self. >> registry _ (Dictionary new >> at: 'content' put: (ContentContainer new root: self); >> yourself)! ! > > 1. Always call super initialize. I know this works in 2.7, but it > breaks in 2.8. > > 2. Register all the objects that reference components that are > returned as children for backtracking. > > This means you need to add the following two lines to the end of your > initialize method in 2.7: > > self session > registerObjectForBacktracking: registry; " for the dictionary " > registerObjectForBacktracking: self " for the menu " > > In 2.8 this is simpler, you implement the message #states to answer > the objects to be backtracked: > > states > ^ Array with: registry with: self > > 3. Thanks to your question I found another severe bug in the > backtracking of dictionaries (there was a long undiscovered one in > Set, but obviously this was not the end). This is fixed and tested > against in 2.8. For 2.7 make sure that you have these two methods: > > Set>>snapshotCopy > ^ self copy > > Dictionary>>restoreFromSnapshot: aDictionary > self keys do: [ :key | self removeKey: key ]. > aDictionary keysAndValuesDo: [ :key :value | self at: key put: > value ] > > Considering all this makes your example work. > > Thanks for providing the example that lead to a solution to this bug. > > Lukas > was not going insane!) Much obliged, John www.pinesoft.co.uk Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |