1 13 package info.magnolia.cms.gui.dialog; 14 15 import info.magnolia.cms.core.Content; 16 import info.magnolia.cms.i18n.MessagesManager; 17 18 import java.text.SimpleDateFormat ; 19 import java.util.Calendar ; 20 import java.util.Date ; 21 22 import javax.jcr.PropertyType; 23 import javax.jcr.RepositoryException; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 28 32 public class DialogDate extends DialogEditWithButton { 33 34 37 protected DialogDate() { 38 } 39 40 43 public void init(HttpServletRequest request, HttpServletResponse response, Content websiteNode, Content configNode) 44 throws RepositoryException { 45 super.init(request, response, websiteNode, configNode); 46 this.getButton().setLabel(MessagesManager.get(getRequest(), "dialog.date.select")); this.getButton().setSaveInfo(false); 49 this.getButton().setOnclick( 50 "mgnlDialogOpenCalendar('" + this.getName() + "'," + this.getConfigValue("time", "false") + ");"); String format = "yyyy-MM-dd"; String pattern = "XXXX-XX-XX"; if (!this.getConfigValue("time", "false").equals("false")) { format += "'T'HH:mm:ss"; pattern += "TXX:XX:XX"; } 57 this.setConfig("onchange", "mgnlDialogDatePatternCheck(this,'" + pattern + "');"); if (this.getWebsiteNode() != null && this.getWebsiteNode().getNodeData(this.getName()).isExist()) { 59 Calendar valueCalendar = this.getWebsiteNode().getNodeData(this.getName()).getDate(); 60 Date valueDate = valueCalendar.getTime(); 61 SimpleDateFormat sdf = new SimpleDateFormat (format); 62 this.setValue(sdf.format(valueDate)); 63 this.clearWebsiteNode(); } 65 this.setConfig("type", this.getConfigValue("type", PropertyType.TYPENAME_DATE)); } 68 69 } 70 | Popular Tags |