norbert at hartl.name
Fri Feb 12 19:58:08 UTC 2010
On 12.02.2010, at 17:04, Tony Giaccone wrote:
> On Fri, Feb 12, 2010 at 10:01 AM, Norbert Hartl <norbert at hartl.name> wrote:
> Yes, only coding and not strong concerns. In general using this should be safe. The new selector is meaningful on the class side but AFAIK not on the instance side of your objects. If you are calling new you need to have an implemented method new that easily leads to confusion when you read code.
> In your case and taking the examples from Richard your probably best off using the actionButtons approach.
> Ok, so I think another lightbulb just went off in my head, and something I had totally missed before is now flashing bright red.
> Are you saying that when each of those buttons is pressed a method with that selector is going to be called on the object being edited. IE pressing the Save button is the same as sending [myObject save]?
No, but similar :) By doing "anObject asComponent" you create a component that is displayable in seaside. This component holds your object as a model to act upon. The component that is being generated is of class MAContainerComponent. There is one additional step but I leave it off in order not to confuse you too much. In short I can say that a press of button "save" will call the method "save" on the component not on your object. And that is the problem if you introduce a new button you would have to alter the dynamically generated component to have a method by that name. So this approach is probably not the best for you to use.
So this is a hard topic if you are new to all of this. If you want to understand why the actionButtons work like you need it you need to understand closures/blockcontext. You could otherwise subclass MAContainerComponet and add a "new" method to it. You can then set your class in the description for magritte to use it. Magritte will use your own class to create the component instead the default one. But either way is some of this lightbulb games.
So may best advize is: Don't hesitate to ask questions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the seaside