001: /*
002: * Button.java
003: *
004: * Version: $Revision: 1.2 $
005: *
006: * Date: $Date: 2006/07/13 15:18:53 $
007: *
008: * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040:
041: package org.dspace.app.xmlui.wing.element;
042:
043: /**
044: * A class representing the Button input control. The button input control
045: * allows the user to activate a form submit, where the form information is sent
046: * back to the server.
047: *
048: * @author Scott Phillips
049: */
050:
051: import org.dspace.app.xmlui.wing.Message;
052: import org.dspace.app.xmlui.wing.WingContext;
053: import org.dspace.app.xmlui.wing.WingException;
054:
055: public class Button extends Field {
056: /**
057: * Construct a new field.
058: *
059: * @param context
060: * (Required) The context this element is contained in, such as
061: * where to route SAX events and what i18n catalogue to use.
062: *
063: * @param name
064: * (Required) a non-unique local identifier used to differentiate
065: * the element from its siblings within an interactive division.
066: * This is the name of the field use when data is submitted back
067: * to the server.
068: * @param rend
069: * (May be null) a rendering hint used to override the default
070: * display of the element.
071: */
072: protected Button(WingContext context, String name, String rend)
073: throws WingException {
074: super (context, name, Field.TYPE_BUTTON, rend);
075:
076: params = new Params(context);
077: }
078:
079: /**
080: * Set the button's label, removing any previous label's
081: *
082: * @return A button label's value.
083: */
084: public Value setValue() throws WingException {
085: removeValueOfType(Value.TYPE_RAW);
086: Value value = new Value(context, Value.TYPE_RAW);
087: values.add(value);
088: return value;
089: }
090:
091: /**
092: * Set the button's label, removing any previous label's
093: *
094: * @param characters
095: * (May be null) The button's label as a string.
096: */
097: public void setValue(String characters) throws WingException {
098: Value value = this .setValue();
099: value.addContent(characters);
100: }
101:
102: /**
103: * Set the button's label, removing any previous label's
104: *
105: * @param translate
106: * (Required) A key into the i18n catalogue for translation into
107: * the user's preferred language.
108: */
109: public void setValue(Message translated) throws WingException {
110: Value value = this.setValue();
111: value.addContent(translated);
112: }
113: }
|