使用 Tapestry jwcid 属性和 @Block 组件进行 CSS 分类?
Block 组件如何处理 CSS 类? 我有这样的代码:
<style type="text/css">
.nameColumnHeader { width: 30%; }
.nameColumnValue { width: 30%; vertical-align:top; }
</style>
...
<table>
<tr>
<th><span jwcid="nameColumnHeader@Block">...</span></th>
<th><span jwcid="nameColumnValue@Block">...</span</th>
</tr>
...
</table>
最终,这似乎有效。 即使未指定类属性,样式似乎也已应用。
为什么这有效? 指定类属性(就可维护性而言)不是更好的形式吗? 然而,现在这种代码遍布应用程序,是否值得“修复”它?
How does the Block component handle CSS classes? I have code like this:
<style type="text/css">
.nameColumnHeader { width: 30%; }
.nameColumnValue { width: 30%; vertical-align:top; }
</style>
...
<table>
<tr>
<th><span jwcid="nameColumnHeader@Block">...</span></th>
<th><span jwcid="nameColumnValue@Block">...</span</th>
</tr>
...
</table>
Ultimately, this seems to work. The styles seem to be applied even though the class attribute is not specified.
Why does this work? And wouldn't it be better form to specify the class attribute (in terms of maintainability)? At this point, however, this kind of code is all over the app, is it worth it to 'fix' it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能正在使用 contrib:Table 组件 - 默认情况下,它将类应用于 并生成(或者可能在 中,检查生成的标记)。
这些类的值是根据每个列名称生成的,因此对于“phone”列,它们应该是:phoneColumnHeader 和phoneColumnValue...恰好您有一个类似命名的 jwcid (nameColumnHeader),这增加了混乱。
You're probably using the contrib:Table component - by default it applies classes to the and it generates (or perhaps in the , check the generated markup).
The value for those classes are generated from each column name, so for the 'phone' column they should be: phoneColumnHeader and phoneColumnValue... It just happens that you have a similarly named jwcid (nameColumnHeader) which added to the confusion.