1 20 21 package com.jsptags.navigation.pager; 22 23 import javax.servlet.jsp.*; 24 import javax.servlet.jsp.tagext.*; 25 import com.jsptags.navigation.pager.parser.*; 26 27 public final class IndexTag extends PagerTagSupport { 28 29 private String export = null; 30 31 private IndexTagExport indexTagExport = null; 32 private Object oldItemCount = null; 33 private Object oldPageCount = null; 34 35 36 public final void setExport(String value) throws JspException { 37 if (export != value) { 38 try { 39 indexTagExport = TagExportParser.parseIndexTagExport(value); 40 } catch (ParseException ex) { 41 throw new JspTagException(ex.getMessage()); 42 } 43 } 44 export = value; 45 } 46 47 public final String getExport() { 48 return export; 49 } 50 51 52 public int doStartTag() throws JspException { 53 super.doStartTag(); 54 55 if (indexTagExport != null) { 56 String name; 57 if ((name = indexTagExport.getItemCount()) != null) { 58 oldItemCount = pageContext.getAttribute(name); 59 pageContext.setAttribute(name, 60 new Integer (pagerTag.getItemCount())); 61 } 62 63 if ((name = indexTagExport.getPageCount()) != null) { 64 oldPageCount = pageContext.getAttribute(name); 65 pageContext.setAttribute(name, 66 new Integer (pagerTag.getPageCount())); 67 } 68 } 69 70 return (pagerTag.isIndexNeeded() ? EVAL_BODY_INCLUDE : SKIP_BODY); 71 } 72 73 public int doEndTag() throws JspException { 74 75 if (indexTagExport != null) { 76 String name; 77 if ((name = indexTagExport.getItemCount()) != null) { 78 restoreAttribute(name, oldItemCount); 79 oldItemCount = null; 80 } 81 82 if ((name = indexTagExport.getPageCount()) != null) { 83 restoreAttribute(name, oldPageCount); 84 oldPageCount = null; 85 } 86 } 87 88 super.doEndTag(); 89 90 return EVAL_PAGE; 91 } 92 93 public void release() { 94 export = null; 95 indexTagExport = null; 96 oldItemCount = null; 97 oldPageCount = null; 98 99 super.release(); 100 } 101 } 102 103 104 | Popular Tags |