在幼儿园管理系统中,会议管理>申请会议>修改模块:多个与会人员的回显和修改(编辑)!

来源:互联网 发布:人工智能的理论意义 编辑:程序博客网 时间:2024/04/28 14:04

  在幼儿园管理系统中,会议管理>申请会议>修改模块:多个与会人员的回显(复选框)和修改(编辑)!在处理与会人员的回显(复选框)和修改(编辑)出点问题。无法正确的回显(复选框)出来与会人员和修改(编辑)。

最后终于解决:修改(编辑)的思路是:先把原来的该会议记录下的所有与会人员删除,在添加,即可实现修改(编辑)功能。回显(复选框)的思路是:设置一个flag,判断一下是否要选中(复选框),即可实现复选框的回显。


解决代码如下:

回显代码:

<div class="form-group ">

<label for="userId" class="control-label col-lg-2">与会人员:</label> 
<c:if test="${!empty users}">
<c:forEach items="${users}" var="users" varStatus="s">
<c:set value="true" var="flag" />
<c:forEach items="${participants}" var="participant">
<c:if test="${participant.userId==users.id}">
<label class="checkbox-inline">
<input type="checkbox" id="id"  name="id" value="${users.id}" checked="checked">${users.nickname}<br/>
</label>
<c:set value="false" var="flag" />
</c:if>
                 </c:forEach> 
<c:if test="${flag}">
<label class="checkbox-inline">
<input type="checkbox" id="id"  name="id" value="${users.id}">${users.nickname}<br/>
</label>
 </c:if>           
</c:forEach>
</c:if>
</div>

编辑(修改)代码如下:先删除再添加

@RequestMapping(value = "upt", method = RequestMethod.POST)
    public String upt(Appointment m,Model model,User user) {
        model.addAttribute("action", uptAction);
        model.addAttribute("title", uptTitle);
        model.addAttribute("m", m);
        String[] appointmentId = m.getId().split(",");
        List<Participants> participantsOld = null;
        if(appointmentId.length>0) {
            //得到编辑前,所有有关的与会人员
            Map<String, Object> params = new HashMap<String,Object>();
            params.put("appointmentId", appointmentId[0]);
            participantsOld = participantsService.queryAll(params);
        }
        Appointment oldAppointment = appointmentService.queryBean(appointmentId[0]);
        //得到表单提交过来的user id
        //得到和添加与会人员
        Participants participants = new Participants();
        //新的与会人员
        String userId[] = null;
        //先把原来属于这一条会议记录中会议人员全部删除,在添加
//先查出来所有的user
List<Participants> participants2 = participantsService.queryAll(null);
if(participants2.size()>0) {
for (int j = 0; j < participants2.size(); j++) {
if(oldAppointment.getMeetingId().equals(participants2.get(j).getMeetingId())){
participantsService.deleteBean(participants2.get(j).getId());
}
}
}

        if(isNotEmpty(user.getId())) {
        userId = user.getId().split(",");
        if(userId != null && userId.length > 0) {
        for (int i = 1; i < userId.length; i++) {
        participants.setId(Atools.getOneKeyS());
participants.setAppointmentId(appointmentId[0]);
participants.setMeetingId(oldAppointment.getMeetingId());
participants.setUserId(userId[i]);
participants.setPassword(Atools.getMD5Code("123456"));
//是否进入会议:0没有进入;1进入
       participants.setStatus(0);
       participantsService.addBean(participants);

}
        }
        }
        // 验证
        //end 
        appointmentService.updateBean(m);
        return reList;
    }








1 0