01: /*
02: * License
03: *
04: *
05: * Copyright (c) 2003 Essl Christian. All rights
06: * reserved.
07: *
08: * This Licence is based on the Apache Software Licence Version 1.1.
09: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: *
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: *
17: * 2. Redistributions in binary form must reproduce the above copyright
18: * notice, this list of conditions and the following disclaimer in
19: * the documentation and/or other materials provided with the
20: * distribution.
21: *
22: * 3. The end-user documentation included with the redistribution,
23: * if any, must include the following acknowledgment:
24: * "This product includes software developed by Christian Essl
25: * and others for project Jucas (http://www.jucas.org/)."
26: * Alternately, this acknowledgment may appear in the software itself,
27: * if and wherever such third-party acknowledgments normally appear.
28: *
29: * 4. The names "Jucas" and "Christian Essl" must
30: * not be used to endorse or promote products derived from this
31: * software without prior written permission. For written
32: * permission, please contact essl_christian@jucas.org.
33: *
34: * 5. Products derived from this software may not be called "Jucas"
35: * or "Christian Essl", nor may "Jucas" or "Christian Essl"
36: * appear in their name, without prior written permission
37: * of Christian Essl (jucas@esslchristian.de).
38: *
39: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42: * DISCLAIMED. IN NO EVENT SHALL CHRISTIAN ESSL OR
43: * OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50: * SUCH DAMAGE.
51: * ====================================================================
52: *
53: *
54: */
55: package org.jucas.addon.html;
56:
57: /**
58: * A model which back an html radioelemnt. It can have many values but only one
59: * input value. The useform is:
60: * <code>jucas:bean-name-of-element.selected</code>
61: * @author chris
62: *
63: */
64: public class RadioElement extends StringArrayElement {
65: private String selected;
66:
67: /**
68: * Constructor for RadioElement.
69: */
70: public RadioElement() {
71: super ();
72: }
73:
74: /**
75: * @see org.jucas.addon.html.StringArrayElement#selectionAttr(java.lang.String)
76: */
77: public String selectionAttr(String value) {
78: return getSelected() != null && getSelected().equals(value) ? "checked"
79: : EMPTY_STRING;
80: }
81:
82: /**
83: * Returns the selected.
84: * @return String
85: */
86: public String getSelected() {
87: return selected;
88: }
89:
90: /**
91: * Sets the selected.
92: * @param selected The selected to set
93: */
94: public void setSelected(String selected) {
95: this.selected = selected;
96: }
97:
98: }
|