1
我有一个表格,有一个文本字段ajaxformcomponentupdatingbehavior获取文本字段的值。我将按钮添加到表单,与默认提交不同。在单击TextField旁边的按钮后,我想使用Ajaxformcomponentupdatingbehavior从TextField获取值。检票口通过点击按钮
我的代码如下所示:
private String string;
...
public ..() {
Form form = new Form("form") {
@Override
protected void onSubmit() {
//some code
};
add(form);
TextField textField = new TextField("string", new PropertyModel<String>(this,"string"));
textField.setOutputMarkupId(true);
form.add(textField);
Button button = new Button("evalButton");
form.add(button);
button.add(new AjaxFormComponentUpdatingBehavior("onclick") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.print(textField.getValue());
}
});
的文本字段的值为空,单击该按钮第二次之后,我得到正确的值。如何在点击一次按钮后获得TextField的值?
太好了,它的工作原理与我需要的一样,谢谢..;) –