コード例 #1
0
  /**
   * API to update a UtilityAttribute Usage : /UtilityAttribute/update/{utilityid}/{slno}
   *
   * @param ID of attribute
   * @return name of jsp file to which control is to be returned
   */
  @RequestMapping(
      value = "/utilityattribute/update/{utilityid}/{slno}",
      method = RequestMethod.POST)
  protected String updateUtilityAttribute(
      @PathVariable("utilityid") int utilityid,
      @PathVariable("slno") int slno,
      @ModelAttribute("utilityattribute") UtilityAttributes utilityattr) {

    logger.info(
        "*** in utilityattr update id=** " + slno + " :utilityattr=" + utilityattr.getUtilityid());
    int stat = 0;
    try {
      utilityattr.setUtilityid(utilityid);
      utilityattr.setN_slno(slno);
      if (mastersservice.updateUtilityAttr(utilityattr)) {
        stat = 1;
      }
    } catch (Exception e) {
      logger.info("Exception in update utilityattr  " + e.getMessage());
    }
    // Redirect to list page via main page
    String saveoper = "/API/utilityattribute/create/" + utilityid + "/-1?savestat=" + stat;
    SecurityContext sec = SecurityContextHolder.getContext();
    AbstractAuthenticationToken auth = (AbstractAuthenticationToken) sec.getAuthentication();
    @SuppressWarnings("unchecked")
    Map<String, Object> info = (Map<String, Object>) auth.getDetails();
    info.put("saveoper", saveoper);
    auth.setDetails(info);
    return "redirect:/start.htm";
  }
コード例 #2
0
  /**
   * API to save a new UtilityAttribute Usage : /UtilityAttribute/create
   *
   * @param
   * @return name of jsp file to which control is to be returned
   */
  @RequestMapping(value = "/utilityattribute/create/{uid}/{slno}", method = RequestMethod.POST)
  protected String createUtilityAttribute(
      @ModelAttribute("utilityarrtibute") UtilityAttributes utlyattribute,
      @PathVariable("uid") int utilityid,
      @PathVariable("slno") int slno) {
    int stat = 0;
    try {

      logger.info(" in utility create POST. utility=  " + utlyattribute.getUtilityid());

      int primarykey = mastersservice.insertUtilityAttr(utlyattribute);
      if (primarykey != -1) {
        stat = 1;
      }

    } catch (Exception e) {
      logger.info("Exception in create UtilityAttribute " + e.getMessage());
    }
    //  Redirect control to list page via main page
    String saveoper = "/API/utilityattribute/create/" + utilityid + "/-1?savestat=" + stat;
    SecurityContext sec = SecurityContextHolder.getContext();
    AbstractAuthenticationToken auth = (AbstractAuthenticationToken) sec.getAuthentication();
    @SuppressWarnings("unchecked")
    Map<String, Object> info = (Map<String, Object>) auth.getDetails();

    info.put("saveoper", saveoper);
    auth.setDetails(info);
    return "redirect:/start.htm";
  }