1 16 package org.apache.commons.chain.web.servlet; 17 18 19 import javax.servlet.http.HttpServletRequest ; 20 import org.apache.commons.chain.Catalog; 21 import org.apache.commons.chain.Command; 22 import org.apache.commons.chain.Context; 23 24 25 37 38 public class RequestParameterMapper implements Command { 39 40 41 43 44 private String catalogKey = ChainProcessor.CATALOG_DEFAULT; 45 private String parameter = "command"; 46 47 48 50 51 55 public String getCatalogKey() { 56 57 return (this.catalogKey); 58 59 } 60 61 62 68 public void setCatalogKey(String catalogKey) { 69 70 this.catalogKey = catalogKey; 71 72 } 73 74 75 79 public String getParameter() { 80 81 return (this.parameter); 82 83 } 84 85 86 92 public void setParameter(String parameter) { 93 94 this.parameter = parameter; 95 96 } 97 98 99 101 102 108 public boolean execute(Context context) throws Exception { 109 110 ServletWebContext swcontext = (ServletWebContext) context; 112 HttpServletRequest request = swcontext.getRequest(); 113 String value = request.getParameter(getParameter()); 114 115 Catalog catalog = (Catalog) context.get(getCatalogKey()); 117 Command command = catalog.getCommand(value); 118 return (command.execute(context)); 119 120 } 121 122 123 } 124 | Popular Tags |