如何使用普通 Wicket 根据下拉列表动态地将用户定向到新页面?
这是我的情况:用户选择一个部分(例如从下拉列表中),例如“Section1”、“Section2”或“Section3”。然后他单击“确定”按钮(或某个链接)。
我需要发生的事情:在他单击该按钮/链接后,他将被重定向到所选部分,例如 www.homepage.com/docs#section2
。
到目前为止,我还无法从 Link
的 onClick
方法处理表单,也无法调用一些 clickLink
来自 Button
方法 onSubmit()
的 Link
。
我不想使用 AJAX 或 JavaScript。我该怎么做?
Here is my situation: the user selects a section (for example from a dropdown) such as "Section1," "Section2" or "Section3." Then he clicks the OK button (or some link).
What I need to happen: after he clicks on that button/link, he will be redirected to the selected section, e.g. www.homepage.com/docs#section2
.
So far, I have not been able to process the form from Link
's onClick
method, nor have I been able to call some clickLink
on Link
from the Button
method onSubmit()
.
I would prefer not to use AJAX or JavaScript. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为链接不提交表单。它只是充当到某个地方的链接。要访问您的表单数据,您需要先提交表单。尝试使用 SubmitLink 而不是 Link 并
从 SubmitLink 的 onSubmit 函数调用。
从 Javadoc 来看,这应该可行,但我现在无法测试它。
That's because a Link doesn't submit the form. It just acts as a link to somewhere. To access your formdata you'll need to submit the form first. Try using a SubmitLink instead of a Link and call
from the onSubmit function of the SubmitLink.
Judging from the Javadoc this should work but I can't test it right now.
您尝试过 Link.setAnchor(Component)?
Did you try Link.setAnchor(Component)?