1 16 17 package org.apache.struts.chain; 18 19 20 import org.apache.commons.chain.Command; 21 import org.apache.commons.chain.Context; 22 import org.apache.commons.chain.web.WebContext; 23 import org.apache.struts.config.ModuleConfig; 24 25 26 33 34 public abstract class AbstractSetContentType implements Command { 35 36 37 39 40 private String moduleConfigKey = Constants.MODULE_CONFIG_KEY; 41 42 43 45 46 51 public String getModuleConfigKey() { 52 53 return (this.moduleConfigKey); 54 55 } 56 57 58 65 public void setModuleConfigKey(String moduleConfigKey) { 66 67 this.moduleConfigKey = moduleConfigKey; 68 69 } 70 71 72 74 75 83 public boolean execute(Context context) throws Exception { 84 85 WebContext wcontext = (WebContext) context; 87 ModuleConfig moduleConfig = (ModuleConfig) 88 wcontext.get(getModuleConfigKey()); 89 90 String contentType = 92 moduleConfig.getControllerConfig().getContentType(); 93 if (contentType != null) { 94 setContentType(context, contentType); 95 } 96 return (false); 97 98 } 99 100 101 103 104 110 protected abstract void setContentType(Context context, String contentType); 111 112 113 } 114 | Popular Tags |