Advertisement
Guest User

ObjectAction

a guest
Nov 11th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. public class ObjectAction extends ActionSupport {
  2.  
  3.     /** Serial version UID. */
  4.     private static final long serialVersionUID = 8225105390632222245L;
  5.  
  6.     /** The current object*/
  7.     private Object object;
  8.  
  9.     /** The object's identifier selected by the user */
  10.     private Long objectId;
  11.  
  12.     /** The attachedObject that was edited/added */
  13.     private AttachedObject attachedObject;
  14.  
  15.     /** The object service. */
  16.     @Autowired
  17.     private ObjectService objectService;
  18.  
  19.     private ArrayList<String> objectTypes;
  20.  
  21.    
  22.  
  23.     /**
  24.      * Displays the selected object in the object form.
  25.      *
  26.      * @return the result string.
  27.      */
  28.     public String load() {
  29.         Long id = 0l;
  30.         if (objectId != null) {
  31.             id = objectId;
  32.         } else if (attachedObject.getObject() != null) {
  33.             objectTypes = new ArrayList<String>();
  34.             ObjectType[] allTypes = ObjectType.values();
  35.             for (ObjectType objectType : allTypes) {
  36.                 objectTypes.add(objectType.toString());
  37.             }
  38.             id = attachtObject.getObject().getId();
  39.         }
  40.         if (id == (long) 0) {
  41.             return ERROR;
  42.         } else {
  43.             exam = objectService.loadObject(id);
  44.             return SUCCESS;
  45.         }
  46.     }
  47.  
  48.    
  49.     @Override
  50.     public void validate() {
  51.         // If the object is not set, the object ID has to be set.
  52.         if (object == null && objectId == null) {
  53.             if (attachedObject == null) {
  54.                 addActionError(getText("msg.selectExam"));
  55.             }
  56.         }
  57.     }
  58.  
  59.     public void setObjectService(ObjectService objectService) {
  60.         this.objectService = objectService;
  61.     }
  62.  
  63.     public Long getObjectId() {
  64.         return objectId;
  65.     }
  66.  
  67.     public void setObjectId(Long objectId) {
  68.         this.objectId = objectId;
  69.     }
  70.  
  71.     public Object getObject() {
  72.         return object;
  73.     }
  74.  
  75.     public void setObject(Object object){
  76.         this.object = object;
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement