1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
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
50
51 /**
52 * Construct an instance with empty property values.
53 */
54 public ImageButtonBean() {
55 ;
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
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 }