KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > convert > RadioButtonConverter


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.convert;
14
15 import java.util.Map JavaDoc;
16
17 import org.w3c.dom.Element JavaDoc;
18
19 import com.tonbeller.wcf.ui.RadioButton;
20
21 /**
22  * Created on 14.11.2002
23  *
24  * @author av
25  */

26 public class RadioButtonConverter extends BooleanConverter {
27
28   /**
29    * @see com.tonbeller.wcf.convert.BooleanConverter#isSelected(Element, Map)
30    */

31   public int isSelected(Element JavaDoc elem, Map JavaDoc params) {
32
33     // disabled = true? return
34
if (RadioButton.isDisabled(elem))
35       return UNKNOWN;
36
37     // was the form submitted at all?
38
String JavaDoc id = RadioButton.getId(elem);
39     Object JavaDoc inputAvailable = params.get(id + ".valid");
40     if (inputAvailable == null)
41       return UNKNOWN;
42     
43     String JavaDoc groupId = RadioButton.getGroupId(elem);
44     String JavaDoc[] values = (String JavaDoc[])params.get(groupId);
45     if (values == null)
46       return FALSE;
47     // values.length should be 1, but there may be other booleans with the same name
48
for (int i = 0; i < values.length; i++)
49       if (values[i].equals(id))
50         return TRUE;
51     return FALSE;
52     
53   }
54
55 }
56
Popular Tags