1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.util;
19
20 import java.io.Serializable;
21
22 /***
23 * A simple JavaBean to encapsulate the request parameters sent for an HTML
24 * input element of type image. Such an element causes two parameters to be
25 * sent, one each for the X and Y coordinates of the button press. An instance
26 * of this bean within an <code>ActionForm</code> can be used to capture these
27 * and provide a simple means of detecting whether or not the corresponding
28 * image was selected.
29 *
30 * @version $Rev: 421119 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
31 * $
32 */
33 public class ImageButtonBean implements Serializable {
34
35
36 /***
37 * The X coordinate of the button press.
38 */
39 private String x;
40
41 /***
42 * The Y coordinate of the button press.
43 */
44 private String y;
45
46
47
48 /***
49 * Construct an instance with empty property values.
50 */
51 public ImageButtonBean() {
52 ;
53 }
54
55 /***
56 * Construct an instance with the supplied property values.
57 *
58 * @param x The X coordinate of the button press.
59 * @param y The Y coordinate of the button press.
60 */
61 public ImageButtonBean(String x, String y) {
62 this.x = x;
63 this.y = y;
64 }
65
66 public String getX() {
67 return (this.x);
68 }
69
70 public void setX(String x) {
71 this.x = x;
72 }
73
74 public String getY() {
75 return (this.y);
76 }
77
78 public void setY(String y) {
79 this.y = y;
80 }
81
82
83
84 /***
85 * A convenience method to determine whether or not the corresponding
86 * image element was selected.
87 */
88 public boolean isSelected() {
89 return ((x != null) || (y != null));
90 }
91
92 /***
93 * Return a string representation of this object.
94 */
95 public String toString() {
96 StringBuffer sb = new StringBuffer("ImageButtonBean[");
97
98 sb.append(this.x);
99 sb.append(", ");
100 sb.append(this.y);
101 sb.append("]");
102
103 return (sb.toString());
104 }
105 }