使用 Tapestry jwcid 属性和 @Block 组件进行 CSS 分类?

发布于 2024-07-18 17:24:56 字数 540 浏览 7 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦年海沫深 2024-07-25 17:24:56

您可能正在使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文