KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > form > EditPublicationForm


1 package org.nextime.ion.backoffice.form;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4
5 import org.apache.struts.action.ActionError;
6 import org.apache.struts.action.ActionErrors;
7 import org.apache.struts.action.ActionForm;
8 import org.apache.struts.action.ActionMapping;
9 import org.nextime.ion.framework.xml.XML;
10
11 public class EditPublicationForm extends ActionForm {
12
13     private String JavaDoc date;
14     private String JavaDoc data;
15
16     /**
17      * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
18      */

19     public ActionErrors myValidate(HttpServletRequest JavaDoc request) {
20         ActionErrors errors = new ActionErrors();
21         try {
22             XML.getInstance().getDocument(getData());
23         } catch (Exception JavaDoc e) {
24             ActionError error =
25                 new ActionError("error.general.badXml", e.getMessage());
26             errors.add("data", error);
27         }
28         return errors;
29     }
30
31     /**
32      * @see org.apache.struts.action.ActionForm#reset(ActionMapping, HttpServletRequest)
33      */

34     public void reset(ActionMapping arg0, HttpServletRequest JavaDoc arg1) {
35         setDate(null);
36         setData(null);
37     }
38
39     /**
40      * Returns the date.
41      * @return Date
42      */

43     public String JavaDoc getDate() {
44         return date;
45     }
46
47     /**
48      * Sets the date.
49      * @param date The date to set
50      */

51     public void setDate(String JavaDoc date) {
52         this.date = date;
53     }
54
55     /**
56      * Returns the data.
57      * @return String
58      */

59     public String JavaDoc getData() {
60         return data;
61     }
62
63     /**
64      * Sets the data.
65      * @param data The data to set
66      */

67     public void setData(String JavaDoc data) {
68         if (data != null) {
69             this.data =
70                 data.replaceFirst(
71                     ".*<\\x3Fxml.*\\x3F>",
72                     "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
73             this.data = this.data.replaceAll("ion:lang", "xml:lang");
74             // hack for euro symbol
75
} else {
76             data = null;
77         }
78     }
79
80 }
81
Popular Tags