ligerUI---ListBox(列表框可移动的实例)(2)
后台action:
private JSONArray jsonArray;
public JSONArray getJsonArray() {
return jsonArray;
}
public String getDeviceByAll() throws Exception{
List<Device> deviceList = deviceService.getAll(Device.class);
jsonArray = new JSONArray();
for(Device device:deviceList){
JSONObject obj = new JSONObject();
//listbox对应的数据格式要有text、id字段
obj.put("id",device.getDevId());
obj.put("text",device.getDevName());
jsonArray.add(obj);
}
return SUCCESS;
}
好啦,这样就成功了,当然 我这里是省略了后台如何将json数据传递到前台,因为在我写ligerui的其他组件(ligerGrid,ligerForm)的时候已经写过了,就不再重复说了
效果演示截图:(省略向左向右的移动效果图)

在不勾选数据的情况下,点击“点击”按钮,的效果图如下:

其实在移除的过程中,一开始使用的removeItems()方法,但是测试貌似不可以移除,故采用removeItem()的方法,根据id来移除。。
