我正在将项目从Wicket 1.5.7
迁移到Wicket 6.12
,我得到的错误之一将在下面解释。
@Override
protected void onSubmit() {
final String usernameValue = mail.getModelObject();
//Password is left empty in this particular case
AuthenticatedWebSession.get().signIn(usernameValue,"");
if (!continueToOriginalDestination())
{
setResponsePage(getApplication().getHomePage());
}
}
这是我在更改wicket版本时遇到的错误:操作员! 未定义参数类型无效
注意:我将鼠标悬停在!continueToOriginalDestination
在我对stackoverflow的搜索中,我遇到了这个问题: continueToOriginalDestination does not bring me back to originating page
还在apache wicket上检查了这个主题: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-td4101981.html#a4115437
所以我将代码更改为:
@Override
public void onSubmit() {
final String usernameValue = mail.getModelObject();
AuthenticatedWebSession.get().signIn(usernameValue,"");
setResponsePage(getApplication().getHomePage());
throw new RestartResponseAtInterceptPageException(SignInPage.class);
}
在我的特定情况下,旧情况和代码更改似乎都有效。
!continueToOriginalDestination
?答案 0 :(得分:5)
这有助于
http://www.skybert.net/java/wicket/changes-in-wicket-after-1.5/
在1.5中,您可以执行以下操作以打破一个页面的呈现,转到另一个页面(如登录页面),然后将用户发送回他/她所在的位置:
public class BuyProductPage extends WebPage {
public BuyProductPage() {
User user = session.getLoggedInUser();
if (user null) {
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
}
}
然后在LoginPage.java中将此用户重新定向到他/她登录后的BuyProductPage:
public class LoginPage extends WebPage {
public LoginPage() {
// first, login the user, then check were to send him/her:
if (!continueToOriginalDestination()) {
// redirect the user to the default page.
setResponsePage(HomePage.class);
}
}
}
方法continueToOriginalDestination在Wicket 6中发生了变化,它现在无效,这使得你的代码看起来更神奇,而且比逻辑IMO更小:
public class LoginPage extends WebPage {
public LoginPage() {
// first, login the user, then check were to send him/her:
continueToOriginalDestination();
// Magic! If we get this far, it means that we should redirect the
// to the default page.
setResponsePage(HomePage.class);
}
}