Solving doubleheadervalue of doubleselect doesn't work

I recently worked on a J2EE project and encountered such a problem. The device is in the room and the room is in the building. When adding a device, a secondary linkage between the room and the building is required. To check information, you can use ajax and doubleselect of the s tag. I chose the latter. When I added it, I didn’t encounter any problems, and the problem was solved smoothly. However, when I want to modify the information of the device, I need to modify the secondary linkage above. The headervalue that comes with doubleselect can be used, and an option is added, but the initial value of the second select is not easy to use, that is to say, doubleheadervalue cannot normally meet my needs, Baidu, Google, csdn, etc. After collecting some information, I asked the question again but did not find a reasonable solution.

At the beginning I thought of 3 solutions:

1. Modify the source code of the s tag, DoubleListUIBean, DoubleSelect, AbstractDoubleListTag, DoubleSelectTag, and several vm files. By looking at the html source code and the corresponding java source code, .vm source code, I want to find a way to modify it. If the fiddling is clear, come back and add~

2. Use the JS page to control the selected directly. After trying it, I found that the first one works, but the second one still doesn't work. I'm worried, and it may need to continue to be optimized~

3. Through the understanding of the principle, the default select of doubleselect is the option in the 0th position. The original usage is:

	//Get the list of the first select
    	buildingList = buildingService.findAll();
    	//Assemble the map, assemble the second select
	map = new LinkedHashMap<Integer,List<Room>>();
	or(int i=0;i<buildingList.size();i++){
		Building building = buildingList.get(i);
		roomList = building.getRooms ();
		map.put(building.getId(), roomList);
	}
Of course, the required get and set will not be discussed here. On the page, the selected is placed in the 0th position. In this case, if I want to realize its initialization, the original room and building of the device will be placed in the 0th position. Bits are enough. It should also be noted here that device.room.device in the buildinglist is placed after the 0th bit, and the addition in the map should also be placed in the 0th bit, and then the device.room in the roomlist is placed in the 0th bit. The code is implemented as follows :

		device = deviceService.findById(entityId);
		buildingList = buildingService.findAll();
		//Reorganize the list of the first select
		for(int i=0;i<buildingList.size();i++){
			if(device.getRoom().getBuilding() == buildingList.get(i)){
				buildingList.remove(i);
				buildingList.add(0, device.getRoom().getBuilding());
				break;
			}
		}
		//LinkedHashMap insertion order remains unchanged, not sorted by key
		map = new LinkedHashMap<Integer,List<Room>>();
		//Reorganize the list of the second select
		List <Room> roomList = device.getRoom (). GetBuilding (). GetRooms ();
		for(int i=0;i<roomList.size();i++){
			if(device.getRoom() == roomList.get(i)){
				roomList.remove(device.getRoom());
				roomList.add(0,device.getRoom());
				break;
			}
		}
		
		map.put(device.getRoom().getBuilding().getId(), roomList);
		for(int i=0;i<buildingList.size();i++){
			if(device.getRoom().getBuilding().getId() == buildingList.get(i).getId()){

			}else{
				Building building = buildingList.get(i);
				roomList = building.getRooms ();
				map.put(building.getId(), roomList);
			}
		}
		ActionContext.getContext().put("device", device);



the information I want to modify;


device details, building and room have been initialized


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521636&siteId=291194637