Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ObjectAction extends ActionSupport implements Preparable {
- /** Serial version UID. */
- private static final long serialVersionUID = 8225105390632222245L;
- /** The current exam */
- private Object object;
- /** The object's identifier selected by the user */
- private Long objectId;
- /** The AttachedObject that was edited/added */
- private AttachedObject attachedObject;
- /** The object service. */
- @Autowired
- private ObjectService objectService;
- private ArrayList<String> ojectTypes;
- @Override
- public void prepare() throws Exception {
- objectTypes = new ArrayList<String>();
- ObjectType[] allTypes = ObjectType.values();
- for (ObjectType objectType : allTypes) {
- objectTypes.add(objectType.toString());
- }
- Long id = 0l;
- if (examId != null) {
- id = objectId;
- } else if (attachedObject != null) {
- id = attachedObject.getObject().getId();
- }
- if (id == (long) 0) {
- } else {
- object = objectService.loadObject(id);
- }
- }
- /**
- * Saves the object to the database.
- *
- * @return the result string.
- */
- public String save() {
- objectService.saveObject(object);
- return SUCCESS;
- }
- /**
- * Deletes the selected object from the database.
- *
- * @return the result string.
- */
- public String delete() {
- exam = objectService.loadObject(objectId);
- if (object != null) {
- objectService.deleteObject(object);
- }
- return SUCCESS;
- }
- /**
- * Displays the selected object in the object form.
- *
- * @return the result string.
- */
- public String load() {
- return SUCCESS;
- }
- public String cancel() {
- return SUCCESS;
- }
- @Override
- public void validate() {
- // If the object is not set, the object ID has to be set.
- if (object == null && objectId == null) {
- if (attachedObject == null) {
- addActionError(getText("msg.selectObject"));
- }
- }
- }
- /** all getters and setters */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement