如何根据普通Wicket的下拉列表动态地将用户定向到新页面?

时间:2011-04-26 21:15:55

标签: java navigation anchor wicket

以下是我的情况:用户选择一个部分(例如从下拉列表中),例如“Section1”,“Section2”或“Section3”。然后他点击确定按钮(或某个链接)。

我需要做什么:点击该按钮/链接后,他将被重定向到所选部分,例如www.homepage.com/docs#section2

到目前为止,我无法使用Link的{​​{1}}方法处理表单,也无法在onClick上调用某些clickLink Link方法Button

我不想使用AJAX或JavaScript。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

您是否尝试过Link.setAnchor(Component)

答案 1 :(得分:1)

那是因为链接不提交表单。它只是作为某个地方的链接。要访问您的formdata,您需要先提交表单。尝试使用SubmitLink而不是Link并致电

getRequestCycle().setRequestTarget  
    (new RedirectRequestTarget("www.homepage.com/docs#section2"));

来自SubmitLink的onSubmit函数。 从Javadoc来看,这应该可行,但我现在无法测试它。

A RequestTarget that will send a redirect url to the browser. Use this if you 
want to direct the browser to some external URL, like Google etc, immediately. 
Or if you want to redirect to a Wicket page. If you want to redirect with a 
delay the RedirectPage will do a meta tag redirect with a delay.