1 25 package org.ofbiz.webapp.taglib; 26 27 import java.util.Map ; 28 import javax.servlet.jsp.JspTagException ; 29 import javax.servlet.jsp.tagext.TagSupport ; 30 31 38 public class ParamTag extends TagSupport { 39 40 protected String name = null; 41 protected String mode = null; 42 protected String map = null; 43 protected String alias = null; 44 protected String attribute = null; 45 protected Object paramValue = null; 46 47 public void setName(String name) { 48 this.name = name; 49 } 50 51 public String getName() { 52 return name; 53 } 54 55 public void setMode(String mode) { 56 this.mode = mode; 57 } 58 59 public String getMode() { 60 return this.mode; 61 } 62 63 public void setAttribute(String attribute) { 64 this.attribute = attribute; 65 } 66 67 public String getAttribute() { 68 return attribute; 69 } 70 71 public void setValue(Object paramValue) { 72 this.paramValue = paramValue; 73 } 74 75 public Object getValue() { 76 return paramValue; 77 } 78 79 public void setMap(String map) { 80 this.map = map; 81 } 82 83 public String getMap() { 84 return map; 85 } 86 87 public void setAlias(String alias) { 88 this.alias = alias; 89 } 90 91 public String getAlias() { 92 return this.alias; 93 } 94 95 public int doStartTag() throws JspTagException { 96 AbstractParameterTag sTag = (AbstractParameterTag) findAncestorWithClass(this, AbstractParameterTag.class); 97 98 if (sTag == null) 99 throw new JspTagException ("ParamTag not inside a ServiceTag."); 100 101 if (mode != null && !mode.equals("IN") && !mode.equals("OUT") && !mode.equals("INOUT")) 102 throw new JspTagException ("Invalid mode attribute. Must be IN/OUT/INOUT."); 103 104 if (mode != null && (mode.equals("OUT") || mode.equals("INOUT"))) 105 sTag.addOutParameter(name, (alias != null ? alias : name)); 106 107 if (mode == null || mode.equals("IN") || mode.equals("INOUT")) { 108 Object value = null; 109 110 if (attribute != null) { 111 if (map == null) { 112 value = pageContext.findAttribute(attribute); 113 if (value == null) 114 value = pageContext.getRequest().getParameter(attribute); 115 } else { 116 try { 117 Map mapObject = (Map ) pageContext.findAttribute(map); 118 119 value = mapObject.get(attribute); 120 } catch (Exception e) { 121 throw new JspTagException ("Problem processing map (" + map + ") for attributes."); 122 } 123 } 124 } 125 if (value == null && paramValue != null) { 126 value = paramValue; 127 } 128 129 sTag.addInParameter(name, value); 130 } 131 132 return SKIP_BODY; 133 } 134 135 public int doEndTag() { 136 return EVAL_PAGE; 137 } 138 } 139 | Popular Tags |