Hi,
First of all, please excuze me if it's a stupid question, I'm a newbie with Magritte. Is there a way to add conditions do descriptions "on the fly"? For example I have an object with descriptions, and when I do asComponent addValidatedForm, I would like to add a condition to a description, but this time only. Cheers, Sop Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail, plus sûr, plus simple et plus complet ! Windows Live Hotmail _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
ct: Magritte question
> > Hi, > > First of all, please excuse me if it's a stupid question, I'm > a newbie with Magritte. > > Is there a way to add conditions do descriptions "on the > fly"? For example I have an object with descriptions, and > when I do asComponent addValidatedForm, I would like to add a > condition to a description, but this time only. > > Cheers, > > Sop buildEditorFor: aModel ^(aModel description addCondition:[:memento | ]; asComponentOn: aModel) addValidatedForm; yourself Ramon Leon http://onsmalltalk.com _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> From: [hidden email] > To: [hidden email] > Subject: RE: Magritte question > Date: Fri, 7 Sep 2007 14:19:31 -0700 > > ct: Magritte question > > > > Hi, > > > > First of all, please excuse me if it's a stupid question, I'm > > a newbie with Magritte. > > > > Is there a way to add conditions do descriptions "on the > > fly"? For example I have an object with descriptions, and > > when I do asComponent addValidatedForm, I would like to add a > > condition to a description, but this time only. > > > > Cheers, > > > > Sop > > buildEditorFor: aModel > ^(aModel description > addCondition:[:memento | ]; > asComponentOn: aModel) > addValidatedForm; > yourself Thanks, I Tried this : buildEditorFor: anItem (anItem description addCondition: [:item | (Item repository contains: [:each | each id = item id) not]; asComponentOn: anItem) addValidatedForm; yourself It seems to work fine, but the condition dosen't disappear until the session expires. What am I missing ? > > Ramon Leon > http://onsmalltalk.com > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez d'un filtre antivirus gratuit ! Windows Live Hotmail _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> Thanks, I Tried this : > > buildEditorFor: anItem > (anItem description > addCondition: [:item | (Item repository contains: [:each | > each id = item id) not]; > asComponentOn: anItem) > addValidatedForm; > yourself > > It seems to work fine, but the condition dosen't disappear > until the session expires. > What am I missing ? > > > > Ramon Leon > > http://onsmalltalk.com Likely that you're using the same component for the entire length of the session. You may want to copy the description as well, I don't recall if Magritte still caches its descriptions, so say anItem description copy addCondtion. Ramon Leon http://onsmalltalk.com _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> Likely that you're using the same component for the entire length
> of the > session. You may want to copy the description as well, I don't > recall if > Magritte still caches its descriptions, so say anItem description copy > addCondtion. Yes, you have to copy the description, else your globally cached description ends up with a whole set of conditions. Caching can be disabled by using a different description-builder, however need the descriptions a lot (e.g. searching, persistency) it is really worth to let Magritte only build them once and then cache them. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> From: [hidden email] > Subject: Re: Magritte question > Date: Sat, 8 Sep 2007 11:42:15 +0200 > To: [hidden email] > > > Likely that you're using the same component for the entire length > > of the > > session. You may want to copy the description as well, I don't > > recall if > > Magritte still caches its descriptions, so say anItem description copy > > addCondtion. > > Yes, you have to copy the description, else your globally cached > description ends up with a whole set of conditions. > > Caching can be disabled by using a different description-builder, > however need the descriptions a lot (e.g. searching, persistency) it > is really worth to let Magritte only build them once and then cache > them. > Now I have another problem : buildEditorFor: anItem ^(anItem description copy addCondition: [:memento | (Item repository contains: [:each | memento model id = each not]) not] labelled: 'An item with that id already exists'; asComponentOn: anItem) addValidatedForm; yourself The memento model id doesn't change it's value when I edit it. I saw MACheckedMemento has a #cache and a #original method, maybe I should use them, but I don't know how. Sebastien > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez de 2 Go de stockage ! Windows Live Hotmail _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez de 2 Go de stockage ! Windows Live Hotmail _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
In reply to this post by sop soptwo
> Thank you for your help.
> > Now I have another problem : > > buildEditorFor: anItem > ^(anItem description copy > addCondition: [:memento | (Item repository > contains: [:each | memento model id = each not]) not] > labelled: 'An item with that id already exists'; > asComponentOn: anItem) > addValidatedForm; > yourself > > The memento model id doesn't change it's value when I edit > it. I saw MACheckedMemento has a #cache and a #original > method, maybe I should use them, but I don't know how. > > Sebastien That's because the memento doesn't write to the model until after it passes all its validations. You need to check the pending values, which are in the memento keyed by your descriptions. You don't want to say "memento model id" in your rule, you want to say "memento cache at: YouModel descriptionId" to see it's pending value. Ramon Leon http://onsmalltalk.com _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> From: [hidden email] > To: [hidden email] > Subject: RE: Magritte question > Date: Sat, 8 Sep 2007 13:46:46 -0700 > > > Thank you for your help. > > > > Now I have another problem : > > > > buildEditorFor: anItem > > ^(anItem description copy > > addCondition: [:memento | (Item repository > > contains: [:each | memento model id = each not]) not] > > labelled: 'An item with that id already exists'; > > asComponentOn: anItem) > > addValidatedForm; > > yourself > > > > The memento model id doesn't change it's value when I edit > > it. I saw MACheckedMemento has a #cache and a #original > > method, maybe I should use them, but I don't know how. > > > > Sebastien > > That's because the memento doesn't write to the model until after it passes > all its validations. You need to check the pending values, which are in the > memento keyed by your descriptions. You don't want to say "memento model > id" in your rule, you want to say "memento cache at: YouModel descriptionId" > to see it's pending value. > > Ramon Leon > http://onsmalltalk.com > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez de 2 Go de stockage ! Windows Live Hotmail _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
In reply to this post by Lukas Renggli-2
> Yes, you have to copy the description, else your globally cached > description ends up with a whole set of conditions. > > Caching can be disabled by using a different description-builder, > Hi Lukas, Here you are suggesting the idea of providing a specialized description-builder. May I take the liberty of pointing out again that since the existing description builder uses a class var for "Default" rather than a class instance var as would be preferable for subclassing the existing description builder. best regards Keith > however need the descriptions a lot (e.g. searching, persistency) it > is really worth to let Magritte only build them once and then cache > them. > > Lukas > > _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> May I take the liberty of pointing out again that since the existing
> description builder uses a class var for "Default" rather than a class > instance var as would be preferable for subclassing the existing > description builder. Yes, that's exactly the reason I use a class var ;-) All the users of a description builder use MADescriptionBuilder default If you want to use your own custom description builder, you assign a different one to be used as default: MADescriptionBuilder default: SpecialBuilder new Regards, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Lukas Renggli wrote:
>> May I take the liberty of pointing out again that since the existing >> description builder uses a class var for "Default" rather than a class >> instance var as would be preferable for subclassing the existing >> description builder. >> > > Yes, that's exactly the reason I use a class var ;-) > > All the users of a description builder use > > MADescriptionBuilder default > > If you want to use your own custom description builder, you assign a > different one to be used as default: > > MADescriptionBuilder default: SpecialBuilder new > > Regards, > Lukas > > My typical use case is to use my specialized builder in specific circumstances. I do a SpecialBuilder default to obtain the builder that I want, so I shall change that to SpecialBuilder instance, instead and have instance as the class instance var. thanks Keith _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
I have updated the CustomBuilder pacakge and posted it to the
magritteaddons repository. Could you do me a favour and delete the version mistakenly posted to pier addons. many thanks Keith _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Keith Hodges wrote:
> I have updated the CustomBuilder pacakge and posted it to the > magritteaddons repository. > > Could you do me a favour and delete the version mistakenly posted to > pier addons. > > many thanks > > Keith > for some reason, though pier addons is fine. Keith _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
In reply to this post by keith1y
> Ah I see.
> > My typical use case is to use my specialized builder in specific > circumstances. > I do a > > SpecialBuilder default > > to obtain the builder that I want, so I shall change that to > SpecialBuilder instance, instead and have instance as the class > instance > var. Indeed. I had a different use-case in mind than you do. Of course we can have both strategies together. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |