ILWidgets that are not represented as <div>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ILWidgets that are not represented as <div>

Eli Green-5
While refactoring the data grid, I realized that an ILWidget is always contained in a <div> which makes sense 90% of the time but in the case of the grid, having a widget for each row, it would be nice to be able to over-ride this and make the row widget simple output the <tr> tag directly. My idea was to change ILWidget>>>buildContents from this:

^self newRootElement div

to this:

^(self newRootElement perform: self rootElementTag)

and add:

ILWidget>>>rootElementTag

^#div

(This could be a class method as well but I see no reason to limit its flexibility in case some widget can represent itself multiple ways based on some configuration).

However, I wasn't sure how people felt about the use of perform: in this case. I like this method because it's very simple to override in subclasses and easy to understand. The other option I came up with was:

^self elementOn: (self newRootElement)

ILWidget>>>elementOn: anElement [
        ^anElement div
]

This eliminates the need for a perform: call which some people may not like in this instance but it makes the method a little less clear. Better naming might help.

I would personally vote for the first one but being a smalltalk newbie I thought I would check.

P.S. Sorry for all the noise on github, I'm coming from Subversion and Mercurial and my understanding of git is pretty basic. I'll read up a bit before trying to merge again. :)
Reply | Threaded
Open this post in threaded view
|

Re: ILWidgets that are not represented as <div>

Nicolas Petton
Hi Eli,

ILWidget already has #newRootElement, so what about:

ILWidget>>newRootElement [
    ^self rootElementclass new
]

ILWidget>>rootElementClass [
    ^ILDivElement
]

ILWidget>>buildContents [
        self buildHead: self application page head.
       
        ^self newRootElement
            class: self id;
            build: decorator contents;
            yourself
    ]


Cheers!

Nico

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ILWidgets that are not represented as <div>

Nicolas Petton
Hi,

Eli, I pushed the changes I suggested to master. Does it suits your
needs?

Cheers!

Nico

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ILWidgets that are not represented as <div>

Eli Green-5
Dang. I was trying to do them over here but I'm having tons of
problems with gst under OS X and couldn't even convince it to run 90%
of the time. :)

2010/3/2 Nicolas Petton <[hidden email]>:
> Hi,
>
> Eli, I pushed the changes I suggested to master. Does it suits your
> needs?
>
> Cheers!
>
> Nico
>