Customizing views in Magritte

Lukas Renggli renggli at iam.unibe.ch
Mon Nov 27 16:47:29 MET 2006


Hi Norbert,

> I created a model and I'm able to use it as a component with
> seaside. I have a model where ClassA has a 1:m relationship
> to ClassB. The exception here is that there is a fixed set
> of possible instances for ClassB to choose for the reference
> from ClassA.

Then you should use the MAMultipleOptionDescription and you get 3  
possibilites to choose Widgets from: MAMultiselectListComponent  
(default), MACheckboxGroupComponent and MAListCompositonComponent.  
(see slide 41)

> I read the tutorial.pdf. There are three  possibilities mentioned
> to customize the views for the model. Unfortunately I didn't
> figure out how this is working. The mentioned method defaultContainer
> (which should be overridden) doesn't exist in the magritte version
> I use. (I is the newest from Monticello)

#defaultContainer has been renamed to #descriptionContainer some time  
ago. I have updated slides in the pipeline that I will use during a  
Magritte tutorial next Monday, however they are not quite ready yet.

> I even tried to set a new componentClass in the descriptionFoo
> class method.But with no effect. I'm not sure what I'm doing
> wrong. Magritte seems to ignore every step I take to customize.
> What would be the best way to customize on the class or even
> better on description instance side?

In the Pier Unix Security package there is the following use of  
MAMultipleOptionDescription, where the user can choose among  
different permission objects in an 1:m relation:

PUChangeSecurity>>descriptionPermissions
	^ (MAMultipleOptionDescription selector: #permissions label:  
'Permissions' priority: 310)
		comment: 'Defines the set of permissions used together with the  
selected operation.';
		options: self permissionInstances;
		reference: PUPermission description;
		beSorted;
		yourself

As I wrote above this is using MAMultiselectListComponent as a  
Seaside component. If you want to use checkboxes instead of a list  
you could add "componentClass: MACheckboxGroupComponent" to the cascade.

> Why is there an extra componentRenderer? As far as I figured
> it out componentRenderer is container dependent. What is the
> reason for having a additional method componentRenderer?

#componentRenderer: is defined in the container. It is a visitor used  
to define the layout in which your description components are  
arranged. #componentClass: is defined on every description, it is  
used to provide the Seaside component class responsible to display  
the description.

> What are the best practices for wiring magritte components
> together? The only way I found is to use onAnswer:.

To use #onAnswer: is a pretty good practice. Also #call: is quite  
nice, most of my applications use it like this:

	result := self call: (aModel asComponent
		addValidatedForm;
		yourself).

Hope this helps,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch




More information about the SmallWiki mailing list