1 64 65 package com.jcorporate.expresso.ext.struts.taglib.bean; 66 67 import com.jcorporate.expresso.core.controller.ControllerResponse; 68 import com.jcorporate.expresso.ext.struts.taglib.ControllerUtils; 69 import com.jcorporate.expresso.ext.taglib.MessageUtil; 70 import org.apache.struts.taglib.bean.MessageTag; 71 import org.apache.struts.util.ResponseUtils; 72 73 import javax.servlet.jsp.JspException ; 74 import javax.servlet.jsp.PageContext ; 75 76 77 87 public class ExMessageTag 88 extends MessageTag { 89 public final static String SCHEMA_KEY = "ExMessageTag.SCHEMA"; 90 public String schemaClass = null; 91 92 public void setSchema(String newSchema) { 93 schemaClass = newSchema; 94 } 95 96 public String getSchema() { 97 return schemaClass; 98 } 99 106 public int doStartTag() 107 throws JspException { 108 109 Object [] args = new Object [5]; 111 args[0] = arg0; 112 args[1] = arg1; 113 args[2] = arg2; 114 args[3] = arg3; 115 args[4] = arg4; 116 117 String useSchema = null; 118 String message = null; 119 120 121 if (schemaClass == null) { 122 useSchema = (String ) pageContext.getAttribute(SCHEMA_KEY, 123 PageContext.PAGE_SCOPE); 124 } else { 125 useSchema = schemaClass; 126 pageContext.setAttribute(SCHEMA_KEY, useSchema, 127 PageContext.PAGE_SCOPE); 128 } 129 130 if (useSchema == null) { 131 ControllerResponse myResponse = ControllerUtils.getResponse(pageContext); 132 133 if (myResponse != null) { 134 pageContext.setAttribute(SCHEMA_KEY, myResponse.getSchema(), 135 PageContext.PAGE_SCOPE); 136 } 137 } 138 139 message = MessageUtil.getString(pageContext, key, args); 140 141 if (message == null) { 142 message = key; 143 } 144 145 ResponseUtils.write(pageContext, message); 147 148 return (SKIP_BODY); 150 } 151 } | Popular Tags |