1 package org.jahia.deprecated.taglibs.pagination; 2 3 import java.io.IOException ; 4 5 import javax.servlet.jsp.JspException ; 6 import javax.servlet.jsp.JspWriter ; 7 import javax.servlet.jsp.tagext.BodyTagSupport ; 8 9 import org.jahia.data.containers.JahiaContainerList; 10 import org.jahia.data.containers.JahiaContainerListPagination; 11 import org.jahia.deprecated.taglibs.container.ContainerListTag; 12 import org.jahia.utils.JahiaConsole; 13 14 15 34 public class CListPaginationCurrentPageScrollingValue extends BodyTagSupport { 35 36 private JahiaContainerList containerList = null; 37 private JahiaContainerListPagination cPagination = null; 38 39 private String valueOnly = "true"; 40 41 public void setValueOnly(String value) { 42 if ( value != null ){ 43 this.valueOnly = value.trim().toLowerCase(); 44 } 45 } 46 47 public String getValueOnly() { 48 return this.valueOnly; 49 } 50 51 52 public int doStartTag() { 53 54 56 ContainerListTag containerListTag = (ContainerListTag) findAncestorWithClass(this, ContainerListTag.class); 58 if (containerListTag == null || containerListTag.isDeclarationPass()) { 59 return SKIP_BODY; 60 } 61 62 containerList = containerListTag.getContainerList(); 63 if ( containerList == null ){ 64 return SKIP_BODY; 65 } 66 67 cPagination = containerList.getCtnListPagination(); 68 if ( cPagination == null ){ 69 return SKIP_BODY; 70 } 71 72 String value = cPagination.getScrollingValue(cPagination.getCurrentPageIndex()); 73 if ( value == null ){ 74 return SKIP_BODY; 75 } 76 77 if ( this.valueOnly.equals("false") ) 78 { 79 try { 80 StringBuffer buff = new StringBuffer ("<input type='hidden' name='"); 81 buff.append("ctnscroll_"); 82 buff.append(containerList.getDefinition().getName()); 83 buff.append("' value='"); 84 buff.append(value); 85 buff.append("'>"); 86 value = buff.toString(); 87 } catch ( Throwable t ) { 88 t.printStackTrace(); 89 return SKIP_BODY; 90 } 91 } 92 93 try { 94 JspWriter out = pageContext.getOut(); 95 out.print(value); 96 } catch (IOException ioe) { 97 JahiaConsole.println("CListPaginationCurrentPageScrollingValue: doStartTag ",ioe.toString()); 98 } 99 return SKIP_BODY; 100 } 101 102 public int doEndTag() throws JspException { 103 containerList = null; 106 cPagination = null; 107 108 valueOnly = "true"; 109 return EVAL_PAGE; 110 } 111 112 } 113 | Popular Tags |