KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > ui > RadioButton


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.ui;
14
15 import org.w3c.dom.Document JavaDoc;
16 import org.w3c.dom.Element JavaDoc;
17
18 import com.tonbeller.wcf.utils.XoplonNS;
19
20
21 public class RadioButton extends Item {
22   public static final String JavaDoc NODENAME = "radioButton";
23
24   public static boolean isRadioButton(Element JavaDoc elem) {
25     return elem.getNodeName().equals(NODENAME);
26   }
27
28   /** set Group id */
29   public static void setGroupId(Element JavaDoc element, String JavaDoc groupId) {
30     XoplonNS.setAttribute(element, "group-id", groupId);
31   }
32
33   /** get group id */
34   public static String JavaDoc getGroupId(Element JavaDoc element) {
35     return XoplonNS.getAttribute(element, "group-id");
36   }
37
38   /** factory function */
39   public static Element JavaDoc createRadioButton(Document JavaDoc doc) {
40     return Item.createItem(doc, NODENAME);
41   }
42
43   /** factory function, using given groupId */
44   public static Element JavaDoc createRadioButton(Document JavaDoc doc, String JavaDoc groupId) {
45     Element JavaDoc radioButton = createRadioButton(doc);
46     setGroupId(radioButton, groupId);
47     return radioButton;
48   }
49
50   /** adds radio button to parent element, using parent's id as group id */
51   public static Element JavaDoc addRadioButton(Element JavaDoc parent) {
52     Element JavaDoc rb = createRadioButton(parent.getOwnerDocument());
53     parent.appendChild(rb);
54     setGroupId(rb, XoplonCtrl.getId(parent));
55     return rb;
56   }
57
58 }
59
Popular Tags