Advertisement
Guest User

AttachedObjectAction

a guest
Nov 12th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. public class AttachedObjectAction extends ActionSupport implements Preparable {
  2.  
  3.     /** Serial version UID */
  4.     private static final long serialVersionUID = 4311471608420886112L;
  5.  
  6.     /** The current attachedObject*/
  7.     private AttachedObject attachedObject;
  8.  
  9.     /** The attachedObject's identifier selected by the user */
  10.     private Long attachedObjectId;
  11.  
  12.  
  13.     /** The attachedObjectservice. */
  14.     @Autowired
  15.     private AttachedObjectService attachedObjectService;
  16.  
  17.     private ArrayList<String> objectTypes;
  18.  
  19.     @Override
  20.     public void prepare() throws Exception {
  21.         objectTypes = new ArrayList<String>();
  22.         ObjectType[] allTypes = ObjectType.values();
  23.         for (ObjectType objectType : allTypes) {
  24.             objectTypes.add(objectType.toString());
  25.         }
  26.     }
  27.  
  28.  
  29.     /**
  30.      * Saves the attachedObject to the database.
  31.      *
  32.      * @return the result string.
  33.      */
  34.     public String save() {
  35.         attachedObjectService.saveAttachedObject(attachedObject);
  36.         return SUCCESS;
  37.     }
  38.  
  39.     /**
  40.      * Deletes the selected attachedObject from the database.
  41.      *
  42.      * @return the result string.
  43.      */
  44.     public String delete() {
  45.         attachedObject = attachedObjectService.loadAttachedObject(attachedObjectId);
  46.         if (attachedObject != null) {
  47.             attachedObjectService.deleteAttachedObject(attachedObject);
  48.         }
  49.         return SUCCESS;
  50.     }
  51.  
  52.     /**
  53.      * Displays the selected attachedObject in the attachedObject form.
  54.      *
  55.      * @return the result string.
  56.      */
  57.     public String load() {
  58.         attachedObject = attachedObjectService.loadAttachedObject(attachedObjectId);
  59.         return SUCCESS;
  60.     }
  61.  
  62.     public String cancel() {
  63.         return SUCCESS;
  64.     }
  65.  
  66.     @Override
  67.     public void validate() {
  68.         // If the attachedObject is not set, the attachedObject ID has to be set.
  69.         if (attachedObject == null && attachedObjectId == null) {
  70.             addActionError(getText("msg.selectAttachedObject"));
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement