java - 如何在 DSpace 中添加包含超长数据的输入表单(反馈)?

标签 java xml dspace

我的老板想在反馈表单中添加一个选择表单,要求用户选择他/她的国家/地区。我可以通过以下方式实现这一目标:

    Select country = form.addItem().addSelect("country ");
    userType.setLabel("Country");
    userType.addOption("","Please select your country");
    userType.addOption("ABW","Aruba");
    userType.addOption("AFG","Afghanistan");
    <----- Rest of countries from A to Z --->
    userType.setOptionSelected(parameters.getParameter("country",""));
    TextArea countryOther = form.addItem().addTextArea("countryOther");
    countryOther.setValue(parameters.getParameter("countryOther", ""));

我想避免代码中包含很长的国家/地区列表。是否有其他选择,例如将国家/地区列表放在单独的位置并仅提取此信息?提前致谢。

最佳答案

一种简单的方法是创建一个配置文件:config/modules/countries.cfg 并填写您的列表,如配置属性:

ABW=Aruba
AFG=Afghanistan
...

然后使用 ConfigurationManager 将它们添加到您的 Select 中

Select country = form.addItem().addSelect("country ");
country.setLabel("Country");
country.addOption("", "Please select your country");

Enumeration<?> countries = ConfigurationManager.propertyNames("countries");
while (countries.hasMoreElements()) {
    String key = (String) countries.nextElement();
    String value = ConfigurationManager.getProperty("countries", key);
    country.addOption(key, value);
}

关于java - 如何在 DSpace 中添加包含超长数据的输入表单(反馈)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26300095/

相关文章:

java - 使用 LibGDX 顺时针旋转图像

java - 如何让Alarm BootReceiver在特定时间发送通知?

c# - 从 XML 配置文件加载和检索键/值对

xml - FFProbe XML XPath

tomcat - 在 dspace 中配置 Solr -home 参数并使更改生效

java - 按字母顺序排列的 ListView

java - 如何确定数组中是否还有未分配的值?

xml - 值不能为空。参数名称:virtualPath-Sitecore

rest - 如何使用 curl 在 Dspace 6 REST API 中上传比特流

dspace - 如何更改 dspace 授权策略?