1 21 package net.mlw.vlh.web.tag; 22 23 import java.util.Locale ; 24 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.jsp.JspException ; 27 28 import net.mlw.vlh.ValueListInfo; 29 import net.mlw.vlh.web.util.DisplayHelper; 30 import net.mlw.vlh.web.util.JspUtils; 31 32 import org.springframework.context.MessageSource; 33 import org.springframework.context.NoSuchMessageException; 34 35 44 public class FocusStatusTag extends ConfigurableTag 45 { 46 47 50 public int doStartTag() throws JspException 51 { 52 ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class); 53 54 Locale local = rootTag.getConfig().getLocaleResolver().resolveLocale((HttpServletRequest ) pageContext.getRequest()); 55 MessageSource message = rootTag.getConfig().getMessageSource(); 56 57 ValueListInfo info = rootTag.getValueList().getValueListInfo(); 58 if (info.isFocusEnabled()) 59 { 60 StringBuffer sb = new StringBuffer (); 61 62 sb.append("<table ").append(getCellAttributes().getCellAttributesAsString()).append(">"); 63 sb.append("\n <tr>"); 64 sb.append(generateFocusStatus(info, message, local, rootTag)); 65 sb.append("\n </tr>"); 66 sb.append("\n <tr>"); 67 JspUtils.write(pageContext, sb.toString()); 68 pageContext.setAttribute("focusStatus" + rootTag.getTableInfo().getId(), new Integer (info.getFocusStatus())); 69 return EVAL_BODY_INCLUDE; 70 } 71 return SKIP_BODY; 72 73 } 74 75 85 private StringBuffer generateFocusStatus(ValueListInfo info, MessageSource message, Locale local, ValueListSpaceTag rootTag) 86 throws NoSuchMessageException, JspException 87 { 88 89 StringBuffer sb = new StringBuffer (""); 90 91 if ((!info.isDoFocus()) || (info.getFocusStatus() == ValueListInfo.FOCUS_FOUND)) 92 { 93 return sb; 94 } 95 96 DisplayHelper displayHelper = rootTag.getConfig().getDisplayHelper(); 97 98 sb.append("\n <td>"); 99 if (info.getFocusStatus() == ValueListInfo.FOCUS_NOT_FOUND) 100 { 101 sb.append(displayHelper.help(pageContext, message.getMessage("focusStatus.notFound", new String [] 102 { info.getFocusValue() }, local))); 103 } 104 else 105 { 106 if (info.getFocusStatus() == ValueListInfo.FOCUS_TOO_MANY_ITEMS) 107 { 108 sb.append(displayHelper.help(pageContext, message.getMessage("focusStatus.tooManyItems", null, local))); 109 } 110 } 111 sb.append("</td>"); 112 String delim = displayHelper.help(pageContext, message.getMessage("paging.delim", null, "", local)); 113 if (delim.length() > 0) 114 { 115 sb.append(delim); 116 } 117 return sb; 118 } 119 120 123 public int doEndTag() throws JspException 124 { 125 ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class); 126 ValueListInfo info = rootTag.getValueList().getValueListInfo(); 127 if (info.isFocusEnabled()) 128 { 129 JspUtils.write(pageContext, "\n </tr>\n</table>"); 130 } 131 132 release(); 133 134 return EVAL_PAGE; 135 } 136 } | Popular Tags |