Exemplo n.º 1
0
 @Action(
     value = "save-material-ajax",
     results = {
       @Result(
           name = "success",
           location = "/WEB-INF/content/ajax-material/material-add-ajax.jsp"),
       @Result(name = "input", location = "/WEB-INF/content/ajax-material/material-add-ajax.jsp")
     })
 public String save() throws Exception {
   try {
     if (materail != null && materailHash != materail.hashCode()) {
       if (materail.getPrefix().equals("") || materail.getPrefix().length() != 2) {
         addFieldError("prefix", Messages.getString("material.empty"));
         return INPUT;
       }
       if (materailService.hasCunjaction(materail.getId(), materail.getPrefix())) {
         addFieldError("prefix", Messages.getString("material.cunj"));
         return INPUT;
       }
       materailService.saveOrUpdate(materail);
       materailService.log(materail, "saveOrUpadate");
       request.setAttribute("materialSuccess", SUCCESS);
       return SUCCESS;
     }
   } catch (Exception e) {
     addFieldError("prefix", Messages.getString("material.cunj"));
   }
   return INPUT;
 }
Exemplo n.º 2
0
 public Long getId(String prefix) {
   Material material =
       (Material)
           getCurrentSession()
               .getNamedQuery("Material.check")
               .setString("prefix", prefix)
               .list()
               .get(0);
   return material.getId();
 }
Exemplo n.º 3
0
 public void prepare() throws Exception {
   if (materail != null && materail.getId() != null) {
     this.materail = materailService.get(materail.getId());
     this.materailHash = materail.hashCode();
   }
 }