001: package com.technoetic.xplanner.forms;
002:
003: import com.technoetic.xplanner.file.File;
004: import org.apache.commons.lang.StringUtils;
005: import org.apache.struts.action.ActionErrors;
006: import org.apache.struts.action.ActionMapping;
007: import org.apache.struts.upload.FormFile;
008:
009: import javax.servlet.http.HttpServletRequest;
010:
011: public class NoteEditorForm extends AbstractEditorForm {
012: private int authorId;
013: private String subject;
014: private String body;
015: private FormFile formFile;
016: private String attachedToType;
017: private int attachedToId;
018: private int attachmentId;
019: private File file;
020:
021: public String getContainerId() {
022: return Integer.toString(getAttachedToId());
023: }
024:
025: public ActionErrors validate(ActionMapping mapping,
026: HttpServletRequest request) {
027: ActionErrors errors = new ActionErrors();
028: if (isSubmitted()) {
029: require(errors, subject, "note.editor.missing_subject");
030: require(errors, authorId, "note.editor.missing_author");
031: if (formFile == null
032: || StringUtils.isEmpty(formFile.getFileName())) {
033: require(errors, body, "note.editor.missing_body");
034: }
035: }
036: return errors;
037: }
038:
039: public void reset(ActionMapping mapping, HttpServletRequest request) {
040: super .reset(mapping, request);
041: subject = null;
042: body = null;
043: formFile = null;
044: authorId = 0;
045: attachedToId = 0;
046: attachedToType = null;
047: }
048:
049: public void setAuthorId(int authorId) {
050: this .authorId = authorId;
051: }
052:
053: public int getAuthorId() {
054: return authorId;
055: }
056:
057: public void setSubject(String subject) {
058: this .subject = subject;
059: }
060:
061: public String getSubject() {
062: return subject;
063: }
064:
065: public void setBody(String body) {
066: this .body = body;
067: }
068:
069: public String getBody() {
070: return body;
071: }
072:
073: public void setFormFile(FormFile formFile) {
074: this .formFile = formFile;
075: }
076:
077: public FormFile getFormFile() {
078: return formFile;
079: }
080:
081: public void setAttachedToType(String attachedToType) {
082: this .attachedToType = attachedToType;
083: }
084:
085: public String getAttachedToType() {
086: return attachedToType;
087: }
088:
089: public void setAttachedToId(int attachedToId) {
090: this .attachedToId = attachedToId;
091: }
092:
093: public int getAttachedToId() {
094: return attachedToId;
095: }
096:
097: public int getAttachmentId() {
098: return attachmentId;
099: }
100:
101: public void setAttachmentId(int attachmentId) {
102: this .attachmentId = attachmentId;
103: }
104:
105: public File getAttachedFile() {
106: return file;
107: }
108:
109: public void setFile(File file) {
110: this.file = file;
111: }
112: }
|