如何自动选择我创建并添加的下拉框中的元素? 下面的代码创建下拉框,我想选择与我的ExportConfiguration对象中的LanguageFormat属性相对应的项目。使用动态创建的元素在检票中选择下拉框元素
编辑:我接受的答案使我转向了正确的轨道。我不得不在值列表中声明属性,导致它自动分配。谢谢!
(Solution)
values.put(
"exportConfigurationLanguageFormat",exportConfiguration.getLanguageFormat());
(/Solution)
//Language Format choices
ArrayList<String> languageFormatArray = new ArrayList<String>();
languageFormatArray.add(firstLanguage);
languageFormatArray.add(firstLanguage + "-" + firstLanguage.toUpperCase());
languageFormatArray.add(firstLanguage + "_" + firstLanguage.toUpperCase());
exportConfigurationLanguageFormat = new DropDownChoice<String>(
"exportConfigurationLanguageFormat", new PropertyModel<String>
(values, "exportConfigurationLanguageFormat"), languageFormatArray);
exportConfigurationLanguageFormat.setRequired(true);
exportConfigurationLanguageFormatFeedback.add(exportConfigurationLanguageFormat);
这是一个很好的建议,@BorisPavlović,你可以在Wicket资源中学习*很多*窥视。总是比javadoc更可靠。 –
感谢您的建议,我现在有一个解决方案,但我会记住下次。我喜欢通过源代码来更好地了解它是如何工作的,只是希望我有更多时间来完成它;) – FooBar