Re: alternate row colours in foreach
i tried this, within my html file class=ognl:(beans.evenodd.next.equals('odd') ? 'odd' : 'even') and this within my page file, bean name=evenodd class=org.apache.tapestry.bean.EvenOdd/ and this produces alternate colour blank rows just above my table and my table is still the same. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
Hi Peter I've been struggling with this alternating row thing for the last couple of days and finally cracked it this morning. Here is what I have: [[Test.html]] table width=100% cellspacing=0 cellpadding=3 tr valign=top td class=labelsspan key=actionAction/span/td td class=labelsspan key=nameName/span/td td class=labelsspan key=phonePhone/span/td td class=labelsspan key=mobileMobile/span/td td class=labelsspan key=addressAddress/span/td td class=labelsspan key=notesNotes/span/td /tr span jwcid=@Foreach source=ognl:clients value=ognl:client index=ognl:rowIndex element=tr class=ognl:rowStyle tdspan jwcid=@Insert value=ognl:rowIndex + 11/span/td tdspan jwcid=@Insert value=ognl:client.nameGeorge Smith/span/td tdspan jwcid=@Insert value=ognl:client.phone 1234/span/td tdspan jwcid=@Insert value=ognl:client.mobile0400100200/span/td tdspan jwcid=@Insert value=ognl:client.address3 Claire Way/span/td tdspan jwcid=@Insert value=ognl:client.notesNo notes/span/td /span tr valign=top td class=trailer colspan=10End of list/td /tr /table [[Test.java]] private int rowIndex = 1; public void setRowIndex(int rowIndex) { this.rowIndex = rowIndex; } public int getRowIndex() { return rowIndex; } public String getRowStyle() { if (rowIndex%2 == 0) return even; return odd; } [[Application.css]] .even { background-color: #f0f0f0; } .odd { background-color: #a0a0a0; } And I'm not going to say HTH as I know it will. Cheers mc PS I'm sure there is another way to do this using a bean but the above does make sense in Tapestry and you not only get the even/odd thing, you also get a row counter. PPS The other bit I did was to move the content of the getRowStyle() method to an application class, I'm going to use this on lots of pages and if I change the names of the even/odd styles I want to do this in one place and not 50. So it became: public String getRowStyle() { return SomeApplicationClass.getRowStyle(rowIndex); } On 30 Jun 2006 at 8:38, Peter Dawn wrote: cant get it to work. am getting an error component For not found in application namespace. am also getting errors for value=entries Attribute value not defined in the DTD for element binding am also getting errors for value=beans.evenOdd.next Attribute value not defined in the DTD for element binding and why is type=For shouldnt it be Foreach, as I am using foreach. any thoughts. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FOCUS Computing - web design Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.7/379 - Release Date: 29/06/2006 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
mate, i dont know what to say. but i am still not able to get it to work. i have tried to put this code before my pagerender method and after but it still does not work. the only other diff i can see is that my foreach comp is within a tr tag and not a span as yours. i am not sure if this is a problem for me or not. any ideas. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
That all looks very complicated. Typically people setup a bean in their page, http://tapestry.apache.org/tapestry4/tapestry/apidocs/org/apache/tapestry/bean/EvenOdd.html . Then, on each iteration of the row you say class=ognl:myBean.next . Also, Foreach should be avoided whenever possible. For is much better in that it works inside/outside of forms without very much effort. On 6/29/06, Peter Dawn [EMAIL PROTECTED] wrote: mate, i dont know what to say. but i am still not able to get it to work. i have tried to put this code before my pagerender method and after but it still does not work. the only other diff i can see is that my foreach comp is within a tr tag and not a span as yours. i am not sure if this is a problem for me or not. any ideas. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jesse Kuhnert Tacos/Tapestry, team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind.
Re: alternate row colours in foreach
HI Peter The HTML needs to be almost identical to mineyou will notice in my span there is a parameter called: element=tr this is the trick that adds the style stuff to the 'tr' tag during rendering. Sounds like you need to remove your 'tr' tag and live with my 'span' tag. Also, if it's still not working, post your html file. Cheers mc On 30 Jun 2006 at 9:52, Peter Dawn wrote: mate, i dont know what to say. but i am still not able to get it to work. i have tried to put this code before my pagerender method and after but it still does not work. the only other diff i can see is that my foreach comp is within a tr tag and not a span as yours. i am not sure if this is a problem for me or not. any ideas. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FOCUS Computing - web design Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.7/379 - Release Date: 29/06/2006 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
murray - my tr tag does have element=tr within it. the problem was that i have a lot of css formatting within my code, and i had a class element within my table tag which was overriding the odd and even element tags. and once i remove that class statement, it works fine. but again thanks for your help. jesse - i agree a cleaner implementation is always preferred. i am using the evenodd bean within contribtable but couldnt get it to work within the foreach component. if i find a way of implementing it, then it would be great, but for the timebeing the result is still the same. thanks to all again. tapestry rocks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
Hi Murray, Peter, The element=tr is not required if you use tr instead of span. Tapestry components like For will automatically use the tag from the template. This doesn't have any side-effects, and keeps your template HTML valid for viewing in a browser or editing in an HTML editor. Cheers, Nick. Murray Collingwood wrote: HI Peter The HTML needs to be almost identical to mineyou will notice in my span there is a parameter called: element=tr this is the trick that adds the style stuff to the 'tr' tag during rendering. Sounds like you need to remove your 'tr' tag and live with my 'span' tag. Also, if it's still not working, post your html file. Cheers mc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
thanks for the info. but where should i specify the colours of the rows. and is eachEntry the value element. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: alternate row colours in foreach
eachEntry is the component id used in HTML eg ... span jwcid=eachEntry binding name=class value=beans.evenOdd.next/ will generate a class attribute with alternating even and odd for each row. tr class=odd tr class=even tr class=odd ... and so on. On 6/29/06, Peter Dawn [EMAIL PROTECTED] wrote: thanks for the info. but where should i specify the colours of the rows. and is eachEntry the value element. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]