On 8/24/07 5:44 PM, in article [EMAIL PROTECTED], "Josh Canfield" <[EMAIL PROTECTED]> wrote:
>> anyway? If the loop can already figure these out, make them read-only >> properties of the loop. Then you could reference them like ${loop_id.index} >> or ${loop_id.value}. >> > That'd be nice in some cases, but there are also times when I want to > be able to access them through my component class. I like being able > to separate out my rendering logic from my page so that I could change > it in one place. For instance, if you want to color rows of a table > its nice to be able to do something like > > <tr class="${rowClass}">...</tr> > > and let the component decide the row colouring scheme based on the > rows position. I suppose you could access the Loop component directly > to ask it it's position when getRowClass() is called. This leaves you > with a pretty clean template, I suppose potentially at the expense of > the class file... Correct. You have two approaches: 1) Use a conditional component in the template and nothing ever touches your page class. 2) Still have a getRowClass() in your page class, but rather than call getSomeIndex(), it'd call getSomeLoop().getIndex(). I'd argue that the latter is even better because it removes ambiguity. By restricting the choice, you don't have arbitrary index properties that can be named differently on a per class/project/developer basis. Rather, you have a uniform approach to accessing that info. Plus, you keep static analysis tools happy. -- Kevin --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]