如何在HTML中的wicket链接上放置参数? [英] How to put a parameter on a wicket link in HTML?

查看:214
本文介绍了如何在HTML中的wicket链接上放置参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wicket有几个创建链接的选项。

Wicket has a couple of options for creating links.

例如。这个

<wicket:link><a href="Page2.html?productId=1694969292874602935">Go to Page 2
</a></wicket:link>

这表明它传入了一个参数。但是,我们无法使用,因为我们需要链接到页面弹出,并且:链接自动链接页面不会这样做。

This shows it passing in a parameter. However, we cant use as we need the linked to page to popup, and :link autolink page doesnt do this.

唯一的其他方式来做链接就像这样:

The only other way to do a link is like this:

<a href="#" wicket:id="launchlink">click here</a>

问题是,使用上面的表示法,如何给它一个设计师可以输入的参数?这样的事情:

The question is, using the above notation, How to I give it a parameter the designers can enter? Something like this:

<a href="#" wicket:id="launchlink" wicket:params="productid=2342">click here</a>

任何想法?

我们可以挂载页面,然后使用硬编码的HTML链接,例如

We could mount the page, then use a hard coded html link, e.g.

    <a href="/mount/launch/?productid=asdf">click here</a>

但是,我们特别不希望此链接成为可收藏的,因为它依赖于登录的会话等。

However, we specifically dont want this link to be bookmarkable as its dependent on logged in session etc.

理想情况下,我们希望能够动态添加一些参数,并使用设计人员手动添加到html页面的一些参数。这听起来太极端了,但你永远不知道?

Ideally, we would want to be able to add some parameters dynamically, and use some that the designer has manually added to the html page. This sounds too extreme to be possible, but you never know?

推荐答案

使用BookmarkablePageLink,覆盖其onInitialize()方法并使用org .apache.wicket.Component.getMarkupAttributes()获取自定义属性值并将其附加到org.apache.wicket.markup.html.link.BookmarkablePageLink.setParameter(String,String)的链接。

Use BookmarkablePageLink, override its onInitialize() method and use org.apache.wicket.Component.getMarkupAttributes() to get the custom attribute value and append it to the link with org.apache.wicket.markup.html.link.BookmarkablePageLink.setParameter(String, String).

这篇关于如何在HTML中的wicket链接上放置参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆