예제 #1
0
 @RequestMapping(value = "create.htm", method = RequestMethod.POST)
 public ModelAndView createTumbon(@ModelAttribute Tumbon tumbon, BindingResult result) {
   logger.info(" Start  ");
   ModelAndView mav = new ModelAndView();
   try {
     new TumbonValidator().validate(tumbon, result);
     if (result.hasErrors()) {
       mav.setViewName("tumbonCreate");
     } else {
       BuckWaRequest request = new BuckWaRequest();
       request.put("tumbon", tumbon);
       BuckWaResponse response = tumbonService.create(request);
       if (response.getStatus() == BuckWaConstants.SUCCESS) {
         mav.addObject("tumbon", new Tumbon());
         mav.addObject("successCode", response.getSuccessCode());
         mav.setViewName("tumbonCreateSuccess");
       } else {
         mav.addObject("errorCode", response.getErrorCode());
         mav.setViewName("tumbonCreate");
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
     mav.addObject("errorCode", "E001");
   }
   return mav;
 }
예제 #2
0
  @RequestMapping(value = "init.htm", method = RequestMethod.GET)
  public ModelAndView initList(HttpServletRequest httpRequest) {
    logger.info(" Start  ");
    ModelAndView mav = new ModelAndView();
    PagingBean bean = new PagingBean();
    mav.addObject("tumbon", new Tumbon());
    mav.addObject("pagingBean", bean);
    mav.setViewName("tumbonList");
    // Search with initial
    int offset = 0;
    bean.setOffset(offset);
    BuckWaRequest request = new BuckWaRequest();
    mav.addObject("tumbon", new Tumbon());
    request.put("pagingBean", bean);
    bean.put("tumbon", new Tumbon());
    BuckWaResponse response = tumbonService.getByOffset(request);
    if (response.getStatus() == BuckWaConstants.SUCCESS) {
      logger.info(" Success ");
      PagingBean beanReturn = (PagingBean) response.getResObj("pagingBean");
      bean.setCurrentPageItem(beanReturn.getCurrentPageItem());
      bean.setTotalItems(beanReturn.getTotalItems());
      mav.addObject("pagingBean", bean);
    } else {
      mav.addObject("errorCode", response.getErrorCode());
    }
    response = aumphurService.getAll();
    if (response.getStatus() == BuckWaConstants.SUCCESS) {
      List<Aumphur> aumphurList = (List<Aumphur>) response.getResObj("aumphurList");
      mav.addObject("aumphurList", aumphurList);
      httpRequest.getSession().setAttribute("aumphurList", aumphurList);
    }

    return mav;
  }
예제 #3
0
  @RequestMapping(value = "search.htm", method = RequestMethod.POST)
  public ModelAndView search(
      HttpServletRequest httpRequest,
      @ModelAttribute Tumbon tumbon,
      @ModelAttribute PagingBean bean) {
    logger.info(" Start  ");
    ModelAndView mav = new ModelAndView();
    mav.setViewName("tumbonList");
    try {
      int offset = ServletRequestUtils.getIntParameter(httpRequest, "pager.offset", 0);
      bean.setOffset(offset);
      BuckWaRequest request = new BuckWaRequest();
      request.put("pagingBean", bean);
      bean.put("tumbon", tumbon);
      BuckWaResponse response = tumbonService.getByOffset(request);
      if (response.getStatus() == BuckWaConstants.SUCCESS) {
        PagingBean beanReturn = (PagingBean) response.getResObj("pagingBean");
        bean.setCurrentPageItem(beanReturn.getCurrentPageItem());
        bean.setTotalItems(beanReturn.getTotalItems());
        mav.addObject("pagingBean", bean);
        mav.addObject("doSearch", "true");
      } else {
        mav.addObject("errorCode", response.getErrorCode());
      }
    } catch (Exception ex) {
      ex.printStackTrace();

      mav.addObject("errorCode", "E001");
    }
    return mav;
  }
예제 #4
0
  @RequestMapping(value = "edit.htm", method = RequestMethod.GET)
  public ModelAndView initEdit(@RequestParam("tumbonId") String tumbonId) {
    logger.info(" Start  ");
    ModelAndView mav = new ModelAndView();
    BuckWaRequest request = new BuckWaRequest();
    request.put("tumbonId", tumbonId);
    BuckWaResponse response = tumbonService.getById(request);
    if (response.getStatus() == BuckWaConstants.SUCCESS) {
      Tumbon tumbon = (Tumbon) response.getResObj("tumbon");

      mav.addObject("tumbon", tumbon);
    } else {
      logger.info("  Fail !!!! :" + response.getErrorCode() + " : " + response.getErrorDesc());
      mav.addObject("errorCode", response.getErrorCode());
    }
    mav.setViewName("tumbonEdit");

    return mav;
  }