001: /*
002: * Created on Apr 5, 2004
003: *
004: * To change the template for this generated file go to
005: * Window>Preferences>Java>Code Generation>Code and Comments
006: */
007: //** Copyright Statement ***************************************************
008: //The Salmon Open Framework for Internet Applications (SOFIA)
009: //Copyright (C) 1999 - 2002, Salmon LLC
010: //
011: //This program is free software; you can redistribute it and/or
012: //modify it under the terms of the GNU General Public License version 2
013: //as published by the Free Software Foundation;
014: //
015: //This program is distributed in the hope that it will be useful,
016: //but WITHOUT ANY WARRANTY; without even the implied warranty of
017: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
018: //GNU General Public License for more details.
019: //
020: //You should have received a copy of the GNU General Public License
021: //along with this program; if not, write to the Free Software
022: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
023: //
024: //For more information please visit http://www.salmonllc.com
025: //** End Copyright Statement ***************************************************
026: package com.salmonllc.html;
027:
028: import com.salmonllc.properties.Props;
029:
030: /**
031: * A renderer for the Page Selector for JSPDataTable, HtmlDataTable, HtmlDataTable2D and JspList, that renders as submit buttons
032: */
033: public class DataTablePageSelectRendererSubmit extends
034: DataTablePageSelectRenderer {
035: protected String _font = Props.FONT_BUTTON;
036:
037: public String generateRowSelector(HtmlComponent comp, String theme,
038: String pageLabel, String pageOfLabel, int page,
039: int firstSubmitButton, int noButtons, int maxPagingButtons,
040: String imageURL) {
041: Props pr = comp.getPage().getPageProperties();
042: String fontStart = pr.getThemeProperty(theme, _font
043: + Props.TAG_START);
044: String fontEnd = pr.getThemeProperty(theme, _font
045: + Props.TAG_END);
046:
047: String buttonBgColor = pr.getThemeProperty(theme,
048: Props.BUTTON_BG_COLOR);
049: String buttonFontStyle = pr.getThemeProperty(theme,
050: Props.BUTTON_FONT_STYLE);
051: String styleClass = pr.getThemeProperty(theme,
052: Props.BUTTON_STYLE_CLASS);
053: String style = "";
054: if (buttonBgColor != null || buttonFontStyle != null) {
055: style = " style=\"";
056: if (buttonBgColor != null)
057: style += "background-color:" + buttonBgColor + ";";
058: if (buttonFontStyle != null)
059: style += buttonFontStyle;
060: style += "\"";
061: }
062:
063: if (styleClass != null)
064: styleClass = " class=\"" + styleClass + "\"";
065:
066: if (fontStart == null) {
067: fontStart = "";
068: fontEnd = "";
069: }
070: StringBuffer sb = new StringBuffer();
071:
072: sb.append(fontStart + pageLabel + ": " + page + " "
073: + pageOfLabel + " " + noButtons + " ");
074:
075: if (noButtons > maxPagingButtons && firstSubmitButton > 0) {
076: if (noButtons > 2)
077: sb.append("<INPUT TYPE=\"SUBMIT\" name=\""
078: + comp.getFullName()
079: + "_page_first\" value=\"<<\"" + style
080: + styleClass + ">");
081: sb.append("<INPUT TYPE=\"SUBMIT\" name=\""
082: + comp.getFullName() + "_page_prior\" value=\"<\""
083: + style + styleClass + ">");
084: }
085: for (int i = 0; (i < noButtons) && (i < maxPagingButtons); i++) {
086: sb.append("<INPUT TYPE=\"SUBMIT\" name=\""
087: + comp.getFullName() + "_page_"
088: + (i + firstSubmitButton) + "\" value=\""
089: + (firstSubmitButton + i + 1) + "\"" + style
090: + styleClass + ">");
091: }
092: if ((firstSubmitButton + (maxPagingButtons == 0 ? 1
093: : maxPagingButtons)) < noButtons) {
094: sb.append("<INPUT TYPE=\"SUBMIT\" name=\""
095: + comp.getFullName() + "_page_next\" value=\">\""
096: + style + styleClass + ">");
097: if (noButtons > 2)
098: sb.append("<INPUT TYPE=\"SUBMIT\" name=\""
099: + comp.getFullName()
100: + "_page_last\" value=\">>\"" + style
101: + styleClass + ">");
102: }
103: sb.append(fontEnd);
104: return sb.toString();
105: }
106: }
|