001: /*
002: * $Id: ImageButtonBean.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.util;
022:
023: import java.io.Serializable;
024:
025: /**
026: * A simple JavaBean to encapsulate the request parameters sent for an HTML
027: * input element of type image. Such an element causes two parameters to be
028: * sent, one each for the X and Y coordinates of the button press. An instance
029: * of this bean within an <code>ActionForm</code> can be used to capture these
030: * and provide a simple means of detecting whether or not the corresponding
031: * image was selected.
032: *
033: * @version $Rev: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
034: * $
035: */
036: public class ImageButtonBean implements Serializable {
037: // ------------------------------------------------------------- Properties
038:
039: /**
040: * The X coordinate of the button press.
041: */
042: private String x;
043:
044: /**
045: * The Y coordinate of the button press.
046: */
047: private String y;
048:
049: // ----------------------------------------------------------- Constructors
050:
051: /**
052: * Construct an instance with empty property values.
053: */
054: public ImageButtonBean() {
055: ; // do nothing
056: }
057:
058: /**
059: * Construct an instance with the supplied property values.
060: *
061: * @param x The X coordinate of the button press.
062: * @param y The Y coordinate of the button press.
063: */
064: public ImageButtonBean(String x, String y) {
065: this .x = x;
066: this .y = y;
067: }
068:
069: public String getX() {
070: return (this .x);
071: }
072:
073: public void setX(String x) {
074: this .x = x;
075: }
076:
077: public String getY() {
078: return (this .y);
079: }
080:
081: public void setY(String y) {
082: this .y = y;
083: }
084:
085: // --------------------------------------------------------- Public Methods
086:
087: /**
088: * A convenience method to determine whether or not the corresponding
089: * image element was selected.
090: */
091: public boolean isSelected() {
092: return ((x != null) || (y != null));
093: }
094:
095: /**
096: * Return a string representation of this object.
097: */
098: public String toString() {
099: StringBuffer sb = new StringBuffer("ImageButtonBean[");
100:
101: sb.append(this .x);
102: sb.append(", ");
103: sb.append(this .y);
104: sb.append("]");
105:
106: return (sb.toString());
107: }
108: }
|