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="labels"><span key="action">Action</span></td>
        <td class="labels"><span key="name">Name</span></td>
        <td class="labels"><span key="phone">Phone</span></td>
        <td class="labels"><span key="mobile">Mobile</span></td>
        <td class="labels"><span key="address">Address</span></td>
        <td class="labels"><span key="notes">Notes</span></td>
  </tr>
  <span jwcid="@Foreach" source="ognl:clients" value="ognl:client" 
                index="ognl:rowIndex" element="tr" class="ognl:rowStyle">
        <td><span jwcid="@Insert" value="ognl:rowIndex + 1">1</span></td>
        <td><span jwcid="@Insert" value="ognl:client.name">George 
Smith</span></td>
        <td><span jwcid="@Insert" value="ognl:client.phone">5555 
1234</span></td>
        <td><span jwcid="@Insert" 
value="ognl:client.mobile">0400100200</span></td>
        <td><span jwcid="@Insert" value="ognl:client.address">3 Claire 
Way</span></td>
        <td><span jwcid="@Insert" value="ognl:client.notes">No notes</span></td>
  </span>
  <tr valign="top">
   <td class="trailer" colspan="10">End 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]

Reply via email to