【发布时间】:2012-12-20 04:09:24
【问题描述】:
我的页面构造函数中有这段代码:
private String selectedAwsId;
private String selectedIsReal;
//these two are actually outside the constructor, and getters and setters for these two strings not shown
List<AwsCredentials> awsCredentials = (List<AwsCredentials>)getAwsCredentials();
List<String> awsIds = new ArrayList<String>();
for (AwsCredentials cred : awsCredentials){
awsIds.add(cred.getAwsId());
}
selectedAwsId = awsIds.get(0);
List<String> yesOrNo = Arrays.asList(new String[] { "sandbox", "real"});
selectedIsReal = "sandbox";
Form selectAwsCredentialsForm = new Form("selectAwsCredentialsForm"){
@Override
public void onSubmit() {
super.onSubmit();
//TODO: why isn't this updating the form?
}
};
add(selectAwsCredentialsForm);
selectAwsCredentialsForm.add(new DropDownChoice("selectAwsCredentialsDropdown", new PropertyModel(this, "selectedAwsId"), awsIds));
selectAwsCredentialsForm.add(new DropDownChoice("selectRealOrSandboxHitsDropdown", new PropertyModel(this, "selectedIsReal"), yesOrNo));
我第一次渲染页面时,效果很好。但是,当我更改任一 DropDownChoices 中的选择并提交表单时,页面不会更改( selectedAwsId 和 selectedIsReal 中的值不会相应更改)。在我对表单如何工作的理解中,我是否遗漏了什么?提交表单时是否刷新整个页面(构造函数是否再次运行?)
【问题讨论】:
-
您能否添加您的代码以提交表单(以防这与您的问题有关)?
-
这是整个代码(我没有从 onSubmit 中删除任何内容)——它不应该自动更新这两个值吗,因为它们是 DropDownChoice 模型的一部分?
标签: wicket