KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > util > ImageButtonBean


1 /*
2  * $Id: ImageButtonBean.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.util;
21
22
23 import java.io.Serializable JavaDoc;
24
25
26 /**
27  * A simple JavaBean to encapsulate the request parameters sent for an HTML
28  * input element of type image. Such an element causes two parameters to be
29  * sent, one each for the X and Y coordinates of the button press. An instance
30  * of this bean within an <code>ActionForm</code> can be used to capture these
31  * and provide a simple means of detecting whether or not the corresponding
32  * image was selected.
33  *
34  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
35  */

36 public class ImageButtonBean implements Serializable JavaDoc {
37
38
39     // ----------------------------------------------------------- Constructors
40

41
42     /**
43      * Construct an instance with empty property values.
44      */

45     public ImageButtonBean() {
46     }
47
48     /**
49      * Construct an instance with the supplied property values.
50      *
51      * @param x The X coordinate of the button press.
52      * @param y The Y coordinate of the button press.
53      */

54     public ImageButtonBean(String JavaDoc x, String JavaDoc y) {
55         this.x = x;
56         this.y = y;
57     }
58
59
60     // ------------------------------------------------------------- Properties
61

62
63     /**
64      * The X coordinate of the button press.
65      */

66     private String JavaDoc x;
67
68     public String JavaDoc getX() {
69         return (this.x);
70     }
71
72     public void setX(String JavaDoc x) {
73         this.x = x;
74     }
75
76
77     /**
78      * The Y coordinate of the button press.
79      */

80     private String JavaDoc y;
81
82     public String JavaDoc getY() {
83          return (this.y);
84     }
85
86     public void setY(String JavaDoc y) {
87         this.y = y;
88     }
89
90
91     // --------------------------------------------------------- Public Methods
92

93
94     /**
95      * A convenience method to determine whether or not the corresponding image
96      * element was selected.
97      */

98     public boolean isSelected() {
99         return ((x != null) || (y != null));
100     }
101
102
103     /**
104      * Return a string representation of this object.
105      */

106     public String JavaDoc toString() {
107         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("ImageButtonBean[");
108         sb.append(this.x);
109         sb.append(", ");
110         sb.append(this.y);
111         sb.append("]");
112         return (sb.toString());
113     }
114
115 }
116
Popular Tags