@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; }
public Long getId(String prefix) { Material material = (Material) getCurrentSession() .getNamedQuery("Material.check") .setString("prefix", prefix) .list() .get(0); return material.getId(); }
public void prepare() throws Exception { if (materail != null && materail.getId() != null) { this.materail = materailService.get(materail.getId()); this.materailHash = materail.hashCode(); } }