【问题标题】:Create an anchor link in Java Tapestry using t:pagelink and context使用 t:pagelink 和上下文在 Java Tapestry 中创建锚链接
【发布时间】:2013-09-24 09:47:12
【问题描述】:

我可以使用此 .tml 代码创建指向页面的链接。这会生成一个指向例如“/path/case314”的链接:

<t:pagelink page="${pageName}" t:context="case">
linked text                             
</t:pagelink>

我想创建一个路径,例如“/path/case314#c​​omment-id-90”。

如果我尝试将链接指向页面内的锚点,就像这样(目标页面中有一个 id 为 #comment-id-${currentComment.id} 的 div):

<t:pagelink page="${pageName}#comment-id-${currentComment.id}" t:context="case">
linked text                             
</t:pagelink>

然后我失去了我的上下文,我得到了默认的 pageName 路径,如下所示:“/path/caseexample#comment-id-90”。哪个不存在,所以 Tapestry 会抛出异常。

如果我尝试手动创建一个类,将链接传递 pageName 作为参数生成“caseexample”而不是正确的“case314”,也会发生同样的事情。

谁能告诉我如何在保持页面链接正常工作的必要上下文的同时构建锚链接?

谢谢!

【问题讨论】:

    标签: java templates tapestry


    【解决方案1】:
    <t:pagelink page="prop:pageName" anchor="comment-id-${currentComment.id}" context="case">linked text</t:pagelink>
    

    【讨论】:

      【解决方案2】:

      仅供参考,请参阅there 以获取可用于页面链接组件的参数列表。

      您会看到 uklance 使用的“锚”参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-12-12
        • 2020-03-02
        • 1970-01-01
        • 2012-05-19
        • 1970-01-01
        • 1970-01-01
        • 2017-05-01
        • 1970-01-01
        相关资源
        最近更新 更多