在我的表单中,我有输入文本,然后dataView:
private class RegistrationForm extends Form<Table> {
private static final long serialVersionUID = 1L;
public RegistrationForm(final Table table) {
super("registrationForm", new CompoundPropertyModel<Table>(table));
setOutputMarkupId(true);
final TextField<String> text = new TextField<String>("name");
add(text);
DataView<Player> dataView = new DataView<Player>("rows", playerDataProvider) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final Item<Player> listItem) {
...
Run Code Online (Sandbox Code Playgroud)
在listItem上,当我双击行时添加ajaxEventBehavior:
listItem.add(new AjaxEventBehavior("ondblclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(final AjaxRequestTarget target) {
System.out.println(table.getName());
}
});
Run Code Online (Sandbox Code Playgroud)
问题是,当我双击表时,它打印null而不是输入TextField中的值.为什么?
我尝试更新模型:
text.updateModel();
Run Code Online (Sandbox Code Playgroud)
或从文本中获取价值:
System.out.println(table.getName() + "bbbbbbbbbbbbbbbbb" + text.getInput() + "vv"
+ text.getValue() + "ff");
Run Code Online (Sandbox Code Playgroud)
但没有成功.
在形式我也提交按钮,当我按下它时,每个想法都有效.双击即可解决问题
AjaxEventBehavior本身不提交表单,因此您没有获得文本字段值.您可以使用以下子类之一:
AjaxFormComponentUpdatingBehavior将只提交FormComponent它附加的那个.它需要附加到FormComponent,因此如果要将其附加到整个表单,则必须使用以下内容ListItem:AjaxFormSubmitBehavior将提交整个表格.这可能是你需要的.所有这些行为都包含在Wicket中,他们的Javadoc就在那里,带有源代码.对于Ajax的东西,检查子类AbstractAjaxBehavior,特别是子类AjaxEventBehavior.
| 归档时间: |
|
| 查看次数: |
1956 次 |
| 最近记录: |