Re: Initialisation of componentClass
Mariano Martinez Peck <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <CAA+-=mU0Ry86Wg++S9Z8EjcPVCpoOKYmH-JNuNK4fWsLtUikKA@mail.gmail.com> |
Hi Iwan, Just for the record, I also workaround this with Jupiter way. Cheers, On Mon, May 16, 2016 at 8:19 AM, Jupiter Jones <[email protected]> wrote: > There are a lot of ways of achieving this, but if you’re after a simple > solution, you can use the: > > MAObject-#propertyAt:put: > > eg. > ^ MAToManyRelationDescription new > ... > componentClass: MyFancyTableComponent; > propertyAt: #fancyItemsPerPage put: 10; > yourself > > Then within MyFancyTableComponent instances you can check for the for the > property in the description with: > > MAObject-hasProperty: #fancyItemsPerPage > or > MAObject-#propertyAt: #fancyItemsPerPage > > As you suggest, you could also subclass MAToManyRelationDescription and > implement the behaviour you want. You can then override > MADescription-C-#defaultComponentClasses to automatically use your > MyFancyTableComponent... but yes, this does add more classes and apparent > complexity - however, it’s all quite neat and everything is in it’s place :) > > Is this what you were after? > > J > > > On 16 May 2016, at 8:09 PM, Iwan Vosloo <[email protected]> wrote: > > > > Hi there, > > > > We have an issue related to magritte-seaside. > > > > When you set the Component to be used on a MADescription, eg: > > > > descriptionThings > > ^ MAToManyRelationDescription new > > ... > > componentClass: MyFancyTableComponent; > > yourself > > > > .. then there is no way (that I am aware of) to initialize the created > MyFancyTableComponent in a customised way. > > > > In the example above, for instance one may have a MyFancyTableComponent > that divides its items into several pages (like an MAReport would do). The > number of items displayed per page has to be hard-coded in > MyFancyTableComponent. It would be nice to have a way to initialize a newly > created instance, something like: > > > > descriptionThings > > ^ MAToManyRelationDescription new > > ... > > componentClass: MyFancyTableComponent; > > initializeComponent: [ :newlyCreatedComponent| > newlyCreatedComponent itemsPerPage: 40 ]; > > yourself > > > > There are, of course, several ways one could do this. I am not > necessarily suggesting the above example as the way to do it... I am just > illustrating the point. > > > > If you do not have such a mechanism, the only thing you can do is > subclass MyFancyTableComponent with the express motivation - to be able to > set a new instance up a certain way. We have a log of code that does this > sort of subclassing. It makes things go really messy eventually. We'd like > to get rid of all those subclasses and rather let the user of a component > 'configure' it appropriately. > > > > Building something like what I am proposing means changes to > magritte-seaside code though. So, if we do it we'd prefer to contribute > upstream. > > > > Has anyone else come across this issue? Any ideas? Worthwhile to others > too? > > > > Regards > > - Iwan > > > > -- > > Reahl, the Python only web framework: http://www.reahl.org > > > > _______________________________________________ > > seaside mailing list > > [email protected] > > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > _______________________________________________ > seaside mailing list > [email protected] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > -- Mariano http://marianopeck.wordpress.com _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside