gpt4 book ai didi

java - 门线模型

转载 作者:行者123 更新时间:2023-12-02 08:04:18 26 4
gpt4 key购买 nike

我仍然没有得到 Wicket 口模型。我在这里做错了什么?当链接 onClick 方法打印它时,filterString 仍然是 ""。

class X extends Panel {
String filterString;
TextField filterTextField;
AjaxLink filterLink;

X(){
filterString = new String("");
filterTextField = new TextField<String>("filterTextField", new PropertyModel<String>(this, "filterString"));
filterLink = new AjaxLink<Void>("filterLink"){
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
params.setFilterString(filterTextField.getModelObject());
System.out.println("BLABLABLA " + filterTextField.getModelObject());
}
};
//add stuff etc
}
}

编辑:

好的,就像 Juha 所说,使用表单是可行的。有时我觉得创建表单感觉有点矫枉过正,但由于这可能是最有 Wicket 风格的事情,所以我将在这里使用它。该类看起来像这样:

public class X extends Panel {
private static final long serialVersionUID = 1L;
public X(String id) {
super(id);
add(new FilterForm("logEntryForm"));
}

public class FilterForm extends Form{
private static final long serialVersionUID = 1L;
private transient String text; //no need to serialize this
public FilterForm(String id) {
super(id);
final TextField<String> contents = new TextField<String>("contents", new PropertyModel<String>(FilterForm.this, "text")); //textArea for user to enter the filter String
add(contents);
add(new AjaxButton("filterButton") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
//do stuff, in my case it was to send the text to the database for filtering out results
}
});
}
}
}

最佳答案

AjaxLink 替换为 FormAjaxButton 或具有 onSubmit() 方法的内容。 AjaxLink 不会提交,因此浏览器不会将输入值发送到服务器。

关于java - 门线模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8410993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com