我在JSF中创建了两个SelectOneMenu:
public void onResponse(String response) {
Log.e(TAG, "onResponse WHOLE: " + response);
try {
JSONObject responseJSONObject = new JSONObject(response);
String arrayString = responseJSONObject.getJSONArray("data").toString();
JSONArray responseJSONArray = new JSONArray(arrayString);
Part tempCarEquipment;
int index = 1;
for (int i = 0; i < responseJSONArray.length(); i++,index++) {
JSONObject object = responseJSONArray.getJSONObject(index);
JSONArray response2 = object.getJSONArray(Integer.toString(index));
String id = object.getJSONObject(Integer.toString(i)).getString("id");
String name= object.getJSONObject(Integer.toString(i)).getString("name");
String quantity= object.getJSONObject(Integer.toString(i)).getString("quantity");
String picture_id= object.getJSONObject(Integer.toString(i)).getString("picture_id");
String code= object.getJSONObject(Integer.toString(i)).getString("code");
tempCarEquipment = new Part(name,quantity,"",picture_id,code,id,"",0);
wholeList.add(tempCarEquipment);
Log.e(TAG, "wholeList: " + wholeList.size());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
我希望将SelectOneMenu menu = new SelectOneMenu();
menu.setId("MenuSelect1" + ctrlCenterResultModel.getId());
UISelectItems item = new UISelectItems();
item.setValue(ctrlCenterResultModel.getBudget());
menu.getChildren().add(item);
SelectOneMenu menu1 = new SelectOneMenu();
menu1.setId("MenuSelect2" + ctrlCenterResultModel.getId());
UISelectItems item1 = new UISelectItems();
item1.setId("Item2"+ctrlCenterResultModel.getId());
item1.setValue(ctrlCenterResultModel.getPeriods());
menu1.getChildren().add(item1);
设置为第二个菜单。当我在第二个ValueChangeListener
中更改值时,我希望有不同的值。例如,在第一个SelectOneMenu
我选择Budget1,我有此预算的期限。接下来我的问题是我在SelectOneMenu
中设置了对象列表,当我得到这个项目的值时,我有String,而不是Object。我知道在XHTML中创建UISelectItems
时是怎么做的,但在这种情况下我用Java代码创建它。