我在按钮的 onSubmit 中有一些逻辑(在表单中),这可能会失败,所以我想使用error(myMessage)
. 但它不起作用,而且看起来很正常:
是否有可能呈现在 onSubmit 中报告错误的反馈面板?
页面上没有使用 ajax。我正在使用检票口 1.5.6
编辑:
我的页面.java
public class MyPage extends WebPage {
private static final Logger logger = Logger.getLogger(MyPage.class);
private static final long serialVersionUID = -8874964120018036584L;
public MyPage(PageParameters parameters) {
super(parameters);
logger.debug("Creating new login page");
add(new MyLoginForm("loginForm"));
}
}
MyLoginForm.java
public class MyLoginForm extends StatelessForm<Void> {
private static final Logger logger = Logger.getLogger(MyLoginForm.class);
private static final long serialVersionUID = -8694389090804630170L;
private MyUser user = new MyUser();
public MyLoginForm(String id) {
super(id);
setOutputMarkupId(true);
logger.debug("Creating new stateless login form");
add(new RequiredTextField<String>("login", new PropertyModel<String>(user, "login")));
add(new PasswordTextField("password", new PropertyModel<String>(user, "password")));
add(new Button("submit"));
add(new FeedbackPanel("feedback"));
}
@Override
public void onSubmit() {
info("test info");
}
}
我的页面.html
<body>
<form wicket:id="loginForm">
<fieldset>
<legend><wicket:message key="form.login.legend"/></legend>
<input type="text" wicket:id="login" />
<input type="password" wicket:id="password" />
<input type="submit" wicket:id="submit" />
<span wicket:id="feedback"></span>
</fieldset>
</form>
</body>
catalina.out
16 May 2012 15:24:20:860 WARN [http-8080-2] [WebSession:135] Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page. Message: [FeedbackMessage message = "test info", reporter = loginForm, level = INFO]
当我尝试覆盖 Button 中的 onSubmit 方法而不是 MyLoginForm 中的方法时,也会发生同样的情况......