[Seaside] Initialisation of componentClass

Jupiter Jones jupiter.jones at mail.com
Mon May 16 11:19:16 UTC 2016


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 <iwan at reahl.org> 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
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list