1 package org.nextime.ion.backoffice.form; 2 3 import javax.servlet.http.HttpServletRequest ; 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 date; 14 private String data; 15 16 19 public ActionErrors myValidate(HttpServletRequest request) { 20 ActionErrors errors = new ActionErrors(); 21 try { 22 XML.getInstance().getDocument(getData()); 23 } catch (Exception e) { 24 ActionError error = 25 new ActionError("error.general.badXml", e.getMessage()); 26 errors.add("data", error); 27 } 28 return errors; 29 } 30 31 34 public void reset(ActionMapping arg0, HttpServletRequest arg1) { 35 setDate(null); 36 setData(null); 37 } 38 39 43 public String getDate() { 44 return date; 45 } 46 47 51 public void setDate(String date) { 52 this.date = date; 53 } 54 55 59 public String getData() { 60 return data; 61 } 62 63 67 public void setData(String 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 } else { 76 data = null; 77 } 78 } 79 80 } 81 | Popular Tags |