替换 Wicket AjaxLink 内的文本
我在我的 .java 文件中创建了一个新的 AjaxLink
add(new AjaxLink("link"){
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("window.open('http://www.cnn.com/2011/WORLD/africa/02/23/libya.protests/index.html?hpt="+T1+"')");
}
});
并将其添加到我的 .html 文件中。
<a href="#" wicket:id="link">TEXT TO REPLACE</a>
url 只是一个示例,但 T1 是动态的,我从我的 .java 文件中获取它。我希望“TEXT TO REPLACE”等于 T1 字符串,但我不知道该怎么做。我尝试创建一个标签并添加它,
<a href="#" wicket:id="link"><span wicket:id="linkLbl"></span></a>
但这会出现错误。
有什么建议吗?
谢谢
I have created a new AjaxLink in my .java file
add(new AjaxLink("link"){
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("window.open('http://www.cnn.com/2011/WORLD/africa/02/23/libya.protests/index.html?hpt="+T1+"')");
}
});
And added it to my .html file
<a href="#" wicket:id="link">TEXT TO REPLACE</a>
The url is just an example but T1 is dynamic and I get that from my .java file. I would like the "TEXT TO REPLACE" to equal the T1 string but I don't know how to do this. I have tried creating a Label and adding it like
<a href="#" wicket:id="link"><span wicket:id="linkLbl"></span></a>
but that gives an error.
Any suggestions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Label
是正确的方向,但您必须确保也在 java 代码中添加标签,它应该是 ajax 链接的子组件。(旁注:您可能需要考虑使用
而不是。在这种情况下,这并不重要,但有在某些情况下,额外的
标记会使您的 HTML 无效。)
The
Label
is the right direction, but you have to make sure that you add the label in the java code as well, it should be a child component of your ajax link.(On a sidenote: you might want to consider using
<wicket:container>
instead of<span>
. In this case it doesn't matter much, but there are cases where an extra<span>
tag would make your HTML invalid.)a) 对链接和标签使用通用模型,b) 不要忘记更新链接
a) Use a common Model for both Link and Label, b) don't forget to update the link