【发布时间】:2017-03-20 23:46:35
【问题描述】:
private Map<String, Map<String, String>> data = new HashMap<String,
Map<String, String>>();
private String type;
private Map<String, String> types;
@PostConstruct
public void init() {
formSchema = new JSONObject();
types = new HashMap<String, String>();
types.put("name", "name");
types.put("address", "address");
types.put("number", "Number");
}
public Map<String, Map<String, String>> getData() {
return data;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, String> getTypes() {
return types;
}
这是我的下拉菜单代码。
我将 xhtml 中的值传递为-
<b:selectOneMenu id="type" value="#{dropdownView.type}"
style="width:150px">
<f:selectItem itemLabel="Select type" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{dropdownView.types}" />
</b:selectOneMenu>
这适用于硬编码值,但我需要使用 JSON 模式填充下拉菜单。
我只是一个初学者。任何人都可以帮助我了解如何将 Json 值(例如姓名、地址和号码)发送到下拉菜单并在下拉菜单中显示值。任何帮助将不胜感激。 提前谢谢你。
以发送json格式为例-
{"form":{"name":"abc","id":"number","date":"true","comment":"largeText"}}
【问题讨论】:
-
1.你JSON的结构是什么?请举个例子。 2. 这个 JSON 将如何提供给您的代码(作为参数传递,从某处加载,由容器注入?
标签: java json xhtml javabeans bootsfaces