I was starting developping with tapestry and I have a question. Actually I have a question about the tables in tapestry and the headers of the tables. I know that if you have a Grid of User classes:
public class User {
public String firstName;
public String lastName;
}
<t:grid source="users" />
Tapestry would produce HTML similar to:
<table>
<thead>
<tr>
<th class="firstName">First Name</th>
<th class="lastName">Last Name</th>
</tr>
</thead>
<tbody>
...
<tr>
<td class="firstName">Traci</td>
<td class="lastName">Lords</td>
</tr>
...
</tbody>
</table>
And my question is how did Tapestry set the values of the headers?
I mean how did tapestry set the value "First Name" from the class "firstName"?
I hope my question is clear.
Thank you.
Tapestry uses reflection to get the names of your properties (firstName
and lastName
) then calls TapestryInternalUtils.toUserPresentable(String id)
to convert it to a more human readable form.
From toUserPresentable()
javadocs:
Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case characters). Thus "userId" becomes "User Id", etc. Also, converts underscore into space (and capitalizes the following word), thus "user_id" also becomes "User Id".