View Javadoc

1   /*
2    * Created on 06.05.2004
3    *
4    * A Formbean that manages adding a new calendar object
5    */
6   package net.stff.ical.gui.struts.formbeans;
7   
8   import java.util.Iterator;
9   
10  import javax.servlet.http.HttpServletRequest;
11  
12  import net.stff.ical.beans.CalendarData;
13  import net.stff.ical.beans.ICal;
14  import net.stff.util.SessionObject;
15  
16  import org.apache.struts.action.ActionError;
17  import org.apache.struts.action.ActionErrors;
18  import org.apache.struts.action.ActionForm;
19  import org.apache.struts.action.ActionMapping;
20  
21  
22  /***
23   * @author buntekuh
24   *
25   */
26  public class EditCalendarsBean extends ActionForm {
27  
28      private String method;
29      private String calname;
30      private String selected;
31      private boolean checked;
32      private String color;
33      private String newname;
34  
35  
36  	/***
37  	 * @return Returns the newname.
38  	 */
39  	public String getNewname() {
40  		return newname;
41  	}
42  	/***
43  	 * @param newname The newname to set.
44  	 */
45  	public void setNewname(String newname) {
46  		this.newname = newname;
47  	}
48       /***
49       * @return Returns the calname.
50       */
51      public String getCalname() {
52          return calname;
53      }
54      /***
55       * @param calname The calname to set.
56       */
57      public void setCalname(String calname) {
58          this.calname = calname;
59      }
60      /***
61       * @return Returns the method.
62       */
63      public String getMethod() {
64          return method;
65      }
66      /***
67       * @param method The method to set.
68       */
69      public void setMethod(String method) {
70          this.method = method;
71      }
72   
73  	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
74  	    
75  	    ActionErrors errors= new ActionErrors();
76  	    
77  	    if (method.equals("add")){
78  			SessionObject so = SessionObject.get(request);
79  			CalendarData data = (CalendarData)so.getObject("icalData", request);
80  			Iterator i= data.getManager().getCalendars(request.getRemoteUser()).iterator();
81  			while (i.hasNext()){
82  			    ICal ical= (ICal)i.next();
83  			    if (ical.getName().equalsIgnoreCase(calname)){
84  			        errors.add("CalendarExists", new ActionError("AddCalendarBean.CalendarExists"));
85  			    }
86  			}
87  	    }
88  
89  	    return errors;
90  	}
91  		
92      /***
93       * @return Returns the color.
94       */
95      public String getColor() {
96          return color;
97      }
98      /***
99       * @param color The color to set.
100      */
101     public void setColor(String color) {
102         this.color = color;
103     }
104     /***
105      * @return Returns the selected.
106      */
107     public String getSelected() {
108         return selected;
109     }
110     /***
111      * @param selected The selected to set.
112      */
113     public void setSelected(String selected) {
114         this.selected = selected;
115     }
116     /***
117      * @return Returns the checked.
118      */
119     public boolean isChecked() {
120         return checked;
121     }
122     /***
123      * @param checked The checked to set.
124      */
125     public void setChecked(boolean checked) {
126         this.checked = checked;
127     }
128 }
129