001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.html;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlHiddenField.java $
024: //$Author: Srufle $
025: //$Revision: 12 $
026: //$Modtime: 4/15/03 1:56a $
027: /////////////////////////
028:
029: import java.util.Hashtable;
030:
031: import com.salmonllc.html.events.ValueChangedEvent;
032:
033: /**
034: * This class will generate a hidden form field.
035: */
036: public class HtmlHiddenField extends HtmlFormComponent {
037:
038: /**
039: * Constructs a new Hidden Field
040: * @param name Each component on a page must have a unique name.
041: * @param value The value to appear on the button.
042: * @param p An HtmlPage object that will be used to initialize any properties in the object.
043: */
044: public HtmlHiddenField(String name, String value, HtmlPage p) {
045: super (name, p);
046: _value = value;
047: }
048:
049: public void generateHTML(java.io.PrintWriter p, int rowNo)
050: throws Exception {
051: String name = getFullName();
052: if (rowNo > -1)
053: name += "_" + rowNo;
054:
055: if (!getVisible())
056: return;
057:
058: _value = getValue(rowNo);
059:
060: String val = _value == null ? "" : _value;
061:
062: String out = "<INPUT TYPE=\"HIDDEN\" name=\"" + name
063: + "\" value=\"" + val + "\">";
064:
065: p.println(out);
066: }
067:
068: public boolean processParms(Hashtable parms, int rowNo)
069: throws Exception {
070: Object oldValue = _value;
071:
072: String name = getFullName();
073: if (rowNo > -1) {
074: name += "_" + rowNo;
075: if (_dsBuff != null)
076: oldValue = _dsBuff.getAny(rowNo, _dsColNo);
077: } else {
078: if (_dsBuff != null)
079: oldValue = _dsBuff.getAny(_dsColNo);
080: }
081:
082: String val[] = (String[]) parms.get(name);
083:
084: if (val != null)
085: _value = val[0];
086: else
087: _value = null;
088:
089: if (_value != null && _value.trim().length() == 0)
090: _value = null;
091:
092: if (!valuesEqual(oldValue, _value)) {
093: String s = null;
094: if (oldValue != null)
095: s = oldValue.toString();
096: ValueChangedEvent e = new ValueChangedEvent(getPage(),
097: this , getName(), getFullName(), s, _value, rowNo,
098: _dsColNo, _dsBuff);
099: addEvent(e);
100: }
101:
102: return false;
103: }
104: }
|