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;
}
這是我的DropDown菜單的代碼。在Java中使用JSON填充DropDown
我傳遞的價值觀在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值(例如,名稱,地址和數字)到下拉菜單,並顯示在Dropdown.Any幫助值將不勝感激。 提前謝謝。
發送JSON格式爲例 -
{ 「形式」:{ 「名」: 「ABC」, 「ID」: 「號碼」, 「日期」: 「真」, 「評論」:」 largeText「}}
1.您的JSON結構是什麼?請舉個例子。 2.這個JSON如何可用於您的代碼(作爲參數傳遞,從某處加載,由容器注入? – kgeorgiy