1 /* 2 * $Id: ImageButtonBean.java 471754 2006-11-06 14:55:09Z husted $ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 package org.apache.struts.util; 22 23 import java.io.Serializable; 24 25 /** 26 * A simple JavaBean to encapsulate the request parameters sent for an HTML 27 * input element of type image. Such an element causes two parameters to be 28 * sent, one each for the X and Y coordinates of the button press. An instance 29 * of this bean within an <code>ActionForm</code> can be used to capture these 30 * and provide a simple means of detecting whether or not the corresponding 31 * image was selected. 32 * 33 * @version $Rev: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) 34 * $ 35 */ 36 public class ImageButtonBean implements Serializable { 37 // ------------------------------------------------------------- Properties 38 39 /** 40 * The X coordinate of the button press. 41 */ 42 private String x; 43 44 /** 45 * The Y coordinate of the button press. 46 */ 47 private String y; 48 49 // ----------------------------------------------------------- Constructors 50 51 /** 52 * Construct an instance with empty property values. 53 */ 54 public ImageButtonBean() { 55 ; // do nothing 56 } 57 58 /** 59 * Construct an instance with the supplied property values. 60 * 61 * @param x The X coordinate of the button press. 62 * @param y The Y coordinate of the button press. 63 */ 64 public ImageButtonBean(String x, String y) { 65 this.x = x; 66 this.y = y; 67 } 68 69 public String getX() { 70 return (this.x); 71 } 72 73 public void setX(String x) { 74 this.x = x; 75 } 76 77 public String getY() { 78 return (this.y); 79 } 80 81 public void setY(String y) { 82 this.y = y; 83 } 84 85 // --------------------------------------------------------- Public Methods 86 87 /** 88 * A convenience method to determine whether or not the corresponding 89 * image element was selected. 90 */ 91 public boolean isSelected() { 92 return ((x != null) || (y != null)); 93 } 94 95 /** 96 * Return a string representation of this object. 97 */ 98 public String toString() { 99 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 }