On Wed, 2006-12-13 at 18:40 +0100, Philippe Marschall
wrote:
2006/12/13, Norbert Hartl
<norbert(a)hartl.name>me>:
Hi,
I'm playing with custom views in Magritte. I have a model
and overwrote descriptionContainer with my own instance of
MAComponentRenderer.
What I'm trying to achieve is to display a text input the
following:
<label for="anyid">labeltext</label>
<input type="text" id="anyid"..../>
As a quick test I changed the renderLabel: to
renderLabel: aDescription
aDescription hasLabel
ifTrue: [ html
label attributeAt: 'for' put: aDescription hash;
with: [ html render: aDescription label ] ]
I need an id attribute in the <input> tag which has the
same content as the for attribute in the <label> tag.
I don't have a glue how to insert an id attribute to the
renderControl:. Is there a way to add an attribute if I only
have a component. I doubt the component description is the
right place to put.
If I only want to change the behaviour of the text input field,
is it best to overwrite the visitStringDescription?
thanks in advance,
This is something that crossed my mind too. To get an id you can use
something like this:
(component childAt: aDescription) ajaxId
Now for the rendering of input tags. I see no way other than changing
or subclassing all the renderer classes.
MAMultiselectListComponent
MASelectListComponent
MATextInputComponent
MATextAreaComponent
MARadioGroupComponent
MARangeComponent
MATextPasswordComponent
MAFileUploadComponent
and whatever I forgot
Honestly I think changing is better because I think it makes sense to
have this as default behavior.
I'm not sure what to change. The only way I see is to have writable
attributes in MAComponent. While the attributes in the MADescription
are class side attributes they could initialize the object attributes
of a MAComponent when the component is created. Okay I'm not that of
an experienced smalltalker but it doesn't sound very good to me, too :)
What do you think?
Have a look at: Magritte-Seaside-pmm.206.
It implements it for some elements. It needs a bit of cleanup, it is
not complete and has some rough edges.
Philippe