1 16 package com.blandware.atleap.webapp.taglib.core.grid; 17 18 import javax.servlet.jsp.JspException ; 19 import javax.servlet.jsp.JspTagException ; 20 import javax.servlet.jsp.PageContext ; 21 import javax.servlet.jsp.tagext.JspFragment ; 22 import javax.servlet.jsp.tagext.SimpleTagSupport ; 23 import java.io.IOException ; 24 25 42 public class CurrentPageTag extends SimpleTagSupport { 43 44 50 public void doTag() throws JspException , IOException { 51 52 PageContext pageContext = (PageContext ) getJspContext(); 53 54 PagesIteratorTag parentPagesIteratorTag = (PagesIteratorTag) findAncestorWithClass(this, PagesIteratorTag.class); 56 57 if ( parentPagesIteratorTag == null ) { 58 JspTagException e = new JspTagException ("Parent tag is invalid! This tag is only valid when nested within 'pagesIterator' tag"); 59 throw e; 60 } 61 62 GridTag parentGridTag = (GridTag) findAncestorWithClass(this, GridTag.class); 63 64 67 Integer pageNumber = parentPagesIteratorTag.getPageNumber(); 68 69 if ( parentGridTag.getCurrentPageNumber().equals(pageNumber) ) { 70 JspFragment body = getJspBody(); 71 if ( body != null ) { 72 body.invoke(null); 73 } 74 } 75 76 } 77 78 } 79 | Popular Tags |