1 18 19 package cowsultants.itracker.web.taglib; 20 21 import java.io.*; 22 import java.util.*; 23 import java.text.*; 24 import javax.servlet.*; 25 import javax.servlet.http.*; 26 import javax.servlet.jsp.*; 27 import javax.servlet.jsp.tagext.*; 28 29 import org.apache.struts.util.*; 30 31 import cowsultants.itracker.ejb.client.resources.*; 32 import cowsultants.itracker.ejb.client.util.*; 33 import cowsultants.itracker.web.util.*; 34 35 40 public class FormatResolutionTag extends BodyTagSupport { 41 public static final String DISPLAY_TYPE_EDIT = "edit"; 42 public static final String DISPLAY_TYPE_VIEW = "view"; 43 44 private String text = null; 45 private String displayType; 46 private int projectOptions; 47 48 public int getProjectOptions() { 49 return projectOptions; 50 } 51 52 public void setProjectOptions(int value) { 53 projectOptions = value; 54 } 55 56 public String getDisplayType() { 57 return displayType; 58 } 59 60 public void setDisplayType(String value) { 61 displayType = value; 62 } 63 64 public int doStartTag() throws JspException { 65 text = null; 66 return EVAL_BODY_BUFFERED; 67 } 68 69 public int doAfterBody() throws JspException { 70 if(bodyContent != null) { 71 String value = bodyContent.getString().trim(); 72 if(value.length() > 0) { 73 text = value; 74 } 75 } 76 return SKIP_BODY; 77 } 78 79 public int doEndTag() throws JspException { 80 StringBuffer results = new StringBuffer (); 81 if(text != null && ! text.trim().equals("")) { 82 Locale currLocale = null; 83 84 HttpSession session = pageContext.getSession(); 85 if(session != null) { 86 currLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY); 87 } 88 89 try { 90 int resolutionNumber = Integer.parseInt(text.trim()); 93 projectOptions = ProjectUtilities.OPTION_PREDEFINED_RESOLUTIONS; 94 } catch(NumberFormatException nfe) { 95 } 96 97 if(ProjectUtilities.hasOption(ProjectUtilities.OPTION_PREDEFINED_RESOLUTIONS, projectOptions)) { 98 try { 99 text = IssueUtilities.checkResolutionName(text, currLocale); 100 } catch(MissingResourceException mre) { 101 } 103 } 104 results.append(text); 105 } 106 ResponseUtils.write(pageContext, results.toString()); 107 clearState(); 108 return (EVAL_PAGE); 109 } 110 111 public void release() { 112 super.release(); 113 clearState(); 114 } 115 116 private void clearState() { 117 text = null; 118 displayType = DISPLAY_TYPE_VIEW; 119 projectOptions = 0; 120 } 121 } 122 | Popular Tags |