Пример #1
0
  public String getByID() throws Exception {
    System.out.println("hello");
    System.out.println("通过ID查找对象");
    String cid = this.request.getParameter("chID");
    int id = Integer.parseInt(cid);
    System.out.println(id);
    Channel cen = (Channel) channelDao.findObjectById(Channel.class, id);
    System.out.println(cen);
    ChannelVo vo = new ChannelVo();
    BeanUtils.copyProperties(vo, cen);
    System.out.println(vo);
    JSONObject obj = new JSONObject();
    System.out.println(cen.getId());
    if (cen.getParentChannel() == null) {

    } else {
      vo.setParentChannel(cen.getParentChannel().getId());
      vo.setParentName(cen.getParentChannel().getName());
    }

    obj.element("chan", vo);
    PrintWriter out = this.response.getWriter();
    out.write(obj.toString());
    System.out.println(obj.toString());
    out.flush();
    return null;
  }
Пример #2
0
 public String update() throws Exception {
   System.out.println(channel);
   String pChannel = this.request.getParameter("parentID");
   System.out.println(pChannel);
   int parId = Integer.parseInt(pChannel);
   Channel chan = (Channel) channelDao.findObjectById(Channel.class, parId);
   channel.setParentChannel(chan);
   channelDao.updateObject(channel);
   return "listAll";
 }
Пример #3
0
 public String add() throws Exception {
   String pChannel = this.request.getParameter("parentID");
   int parId = Integer.parseInt(pChannel);
   Channel chan = (Channel) channelDao.findObjectById(Channel.class, parId);
   channel.setParentChannel(chan);
   boolean flag = channelDao.addObject(channel);
   if (flag) {
     return "listAll";
   } else {
     return "error";
   }
 }