1 13 package info.magnolia.module.admininterface; 14 15 import info.magnolia.cms.beans.runtime.MultipartForm; 16 import info.magnolia.cms.i18n.Messages; 17 import info.magnolia.cms.i18n.MessagesManager; 18 import info.magnolia.cms.servlets.CommandBasedMVCServletHandler; 19 import info.magnolia.cms.util.RequestFormUtil; 20 import info.magnolia.cms.util.Resource; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.commons.lang.StringUtils; 26 import org.slf4j.Logger; 27 import org.slf4j.LoggerFactory; 28 29 30 35 36 public abstract class PageMVCHandler extends CommandBasedMVCServletHandler { 37 38 41 Logger log = LoggerFactory.getLogger(PageMVCHandler.class); 42 43 46 protected static final String COMMAND_PARAMETER_NAME = "command"; 47 48 protected static final String COMMAND_SHOW = "show"; 50 protected static final String VIEW_SHOW = "show"; 52 55 private MultipartForm form; 56 57 60 private Messages msgs; 61 62 65 private RequestFormUtil params; 66 67 73 public PageMVCHandler(String name, HttpServletRequest request, HttpServletResponse response) { 74 super(name, request, response); 75 76 setForm(Resource.getPostedForm(request)); 77 setParams(new RequestFormUtil(request, getForm())); 78 setMsgs(MessagesManager.getMessages()); 79 } 80 81 84 public void init() { 85 super.init(); 86 if (StringUtils.isEmpty(this.getCommand())) { 87 this.setCommand(COMMAND_SHOW); 88 } 89 } 90 91 95 public String show() { 96 return VIEW_SHOW; 97 } 98 99 102 protected void setForm(MultipartForm form) { 103 this.form = form; 104 } 105 106 109 protected MultipartForm getForm() { 110 return form; 111 } 112 113 116 protected void setMsgs(Messages msgs) { 117 this.msgs = msgs; 118 } 119 120 123 protected Messages getMsgs() { 124 return msgs; 125 } 126 127 130 protected void setParams(RequestFormUtil params) { 131 this.params = params; 132 } 133 134 137 protected RequestFormUtil getParams() { 138 return params; 139 } 140 } | Popular Tags |