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.Globals; 30 import org.apache.struts.action.*; 31 import org.apache.struts.util.*; 32 33 import cowsultants.itracker.ejb.client.models.*; 34 import cowsultants.itracker.ejb.client.resources.*; 35 import cowsultants.itracker.web.util.*; 36 37 public class FormatIssueOwnerTag extends TagSupport { 38 private String emptyKey = "itracker.web.generic.unassigned"; 39 private String format; 40 private IssueModel issue; 41 42 public String getFormat() { 43 return format; 44 } 45 46 public void setFormat(String value) { 47 format = value; 48 } 49 50 public IssueModel getIssue() { 51 return issue; 52 } 53 54 public void setIssue(IssueModel value) { 55 issue = value; 56 } 57 58 public String getEmptyKey() { 59 return emptyKey; 60 } 61 62 public void setEmptyKey(String value) { 63 emptyKey = value; 64 } 65 66 public int doStartTag() throws JspException { 67 return SKIP_BODY; 68 } 69 70 public int doEndTag() throws JspException { 71 String value = ""; 72 Locale currLocale = null; 73 74 HttpSession session = pageContext.getSession(); 75 if(session != null) { 76 currLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY); 77 } 78 79 if(issue == null || issue.getOwnerId() == null || issue.getOwnerId().intValue() < 0) { 80 value = ITrackerResources.getString(emptyKey, currLocale); 81 } else { 82 try { 83 if("short".equalsIgnoreCase(format)) { 84 value = (issue.getOwnerFirstName().length() > 0 ? issue.getOwnerFirstName().substring(0,1).toUpperCase() + "." : "") + 85 " " + issue.getOwnerLastName(); 86 } else { 87 value = issue.getOwnerFirstName() + " " + issue.getOwnerLastName(); 88 } 89 } catch(Exception e) { 90 value = ITrackerResources.getString(emptyKey, currLocale); 91 } 92 } 93 ResponseUtils.write(pageContext, value); 94 clearState(); 95 return EVAL_PAGE; 96 } 97 98 public void release() { 99 super.release(); 100 clearState(); 101 } 102 103 private void clearState() { 104 emptyKey = "itracker.web.generic.unassigned"; 105 format = null; 106 issue = null; 107 } 108 } 109 | Popular Tags |