All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.viaoa.html.OADataTable Maven / Gradle / Ivy

/* 
This software and documentation is the confidential and proprietary 
information of ViaOA, Inc. ("Confidential Information").  
You shall not disclose such Confidential Information and shall use 
it only in accordance with the terms of the license agreement you 
entered into with ViaOA, Inc..

ViaOA, Inc. MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. ViaOA, Inc. SHALL NOT BE LIABLE FOR ANY DAMAGES
SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
THIS SOFTWARE OR ITS DERIVATIVES.
 
Copyright (c) 2001 ViaOA, Inc.
All rights reserved.
*/ 

/******
bottom row ....


    
        >
            
ALT="Previous" border="0"> " <%=table.getCommand("cmdNew").getSourceTag()%> src="images/new.gif" ALT="New" border="0"> ALT="Next" border="0">
<%= table.getCount()%>     Page <%=table.getPageLinks(table.getHub().getCount(), 10)%>
******/ package com.viaoa.html; import java.util.*; import java.lang.reflect.*; import com.viaoa.hub.*; import com.viaoa.object.*; import com.viaoa.ds.*; import com.viaoa.util.*; public class OADataTable extends OAHtmlComponent { private static final long serialVersionUID = 1L; protected int scrollAmt; protected int currentPage; protected int maxCount; protected int pageDisplayCount; protected OAHtmlComponent compDefault; public OADataTable(Hub hub, int scrollAmt, int maxCount, int pageDisplayCount) { this.scrollAmt = scrollAmt; this.maxCount = maxCount; this.pageDisplayCount = pageDisplayCount; setHub(hub); } public int getScrollAmount() { return scrollAmt; } public int getTopRow() { init(); return currentPage * scrollAmt; } public int getMaxCount() { return maxCount; } private int newListCount; protected void init() { /* 20160118 remove hub.data.datax.newListCount if (HubDataDelegate.getNewListCount(hub) != newListCount) { newListCount = HubDataDelegate.getNewListCount(hub); currentPage = 0; } */ } public void setDefaultComponent(OAHtmlComponent comp) { this.compDefault = comp; } protected void afterSetValuesInternal() { if (bUseDefault && compDefault != null) compDefault.afterSetValuesInternal(); } protected @Override void beforeSetValuesInternal() { bUseDefault = false; if (compDefault != null) compDefault.beforeSetValuesInternal(); } private boolean bUseDefault; protected void setValuesInternal(String nameUsed, String[] values) { // called by OAForm bUseDefault = false; init(); if (nameUsed == null || values == null || values.length != 1) return; String cmd = values[0]; if (cmd.length() < 2) return; char ch = cmd.charAt(0); ch = Character.toLowerCase(ch); if (ch == 'p') { int x = OAConv.toInt(cmd.substring(1)); currentPage = x; } else if (ch == 'r') { int x = OAConv.toInt(cmd.substring(1)); if (x >= 0) hub.setPos(x); bUseDefault = true; } if (compDefault != null) compDefault.setValuesInternal(nameUsed, values); } protected String processCommand(OASession session, OAForm form, String command) { if (bUseDefault && compDefault != null) return compDefault.processCommand(session, form, ""); return null; } public String getNavHtml() { init(); if (scrollAmt == 0) return ""; int totalObjects = hub.getSize(); if (maxCount > 0 && totalObjects > maxCount) totalObjects = maxCount; int totalPages = (int) Math.ceil(((double)totalObjects) / ((double)scrollAmt)); if (currentPage > totalPages) currentPage = 0; int beginPage = currentPage - ((int) pageDisplayCount/2); if (beginPage < 0) beginPage = 0; int endPage = beginPage + (pageDisplayCount-1); if (endPage >= totalPages) { beginPage = totalPages - pageDisplayCount; if (beginPage < 0) beginPage = 0; } // recalc end page endPage = beginPage + (pageDisplayCount-1); if (endPage >= totalPages) endPage = (totalPages - 1); StringBuffer sb = new StringBuffer(256); sb.append("
    "); if (maxCount > 0 && totalObjects >= maxCount) { sb.append("
  • (only displaying the first " + maxCount + " selected)  
  • "); } else { sb.append("
  • (" + totalObjects + " selected)  
  • "); } if (totalPages > 0) { sb.append("
  • Page "+ (currentPage+1) + " of " + totalPages + "  
  • "); } if (totalPages > 1) { String dis = (currentPage > 0) ? "" : " disablelink"; sb.append("
  • \u00ab
  • "); int x = currentPage - 1; if (x < 0) x = 0; sb.append("
  • \u00bb
  • "); for (int i = beginPage; i <= endPage; i++) { String s = (i == currentPage) ? " class='oaTableNavCurrentPage'" : ""; sb.append("
  • "+(i+1)+"
  • "); } x = currentPage + 1; if (x >= totalPages) x = currentPage; dis = (currentPage < (totalPages-1)) ? "" : " disablelink"; sb.append("
  • \u00bb
  • "); dis = (currentPage+1 != totalPages) ? "" : " disablelink"; sb.append("
  • \u00bb\u00bb
  • "); } sb.append("
"); return new String(sb); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy