1 package com.instantbank.collections.basicInfo.web;
2
3 import java.io.ByteArrayInputStream;
4 import java.io.Serializable;
5 import oracle.xml.parser.v2.DOMParser;
6 import oracle.xml.parser.v2.XMLDocument;
7 import org.w3c.dom.NodeList;
8 import com.instantbank.collections.basicInfo.ejb.BasicInfoServices;
9 import com.instantbank.collections.basicInfo.ejb.BasicInfoServicesHome;
10 import com.instantbank.collections.util.ServiceLocator;
11 import com.instantbank.collections.util.StringFormat;
12
13
19 public class BasicInfoBean
20 implements Serializable {
21
22 public BasicInfoBean() { }
23
24
25 public String getCountriesOptions() {
26 String code;
27 DOMParser docParser = new DOMParser();
28 BasicInfoServicesHome home;
29 String name;
30 NodeList nlCode;
31 NodeList nlName;
32 String s = "";
33 BasicInfoServices services;
34 ByteArrayInputStream stream;
35 String xml;
36 XMLDocument xmlDoc = null;
37
38 try {
39 home = (BasicInfoServicesHome)ServiceLocator.instance().createEJB("BasicInfoServicesHome", BasicInfoServicesHome.class, false);
40 services = home.create();
41 xml = services.getCountries();
42 stream = new ByteArrayInputStream(xml.getBytes());
43 docParser.setValidationMode(false);
44 docParser.parse(stream);
45 xmlDoc = docParser.getDocument();
46 nlCode = xmlDoc.selectNodes("/CountriesList/Country/code/text()");
47 nlName = xmlDoc.selectNodes("/CountriesList/Country/name/text()");
48
49 for(int i = 0; i < nlCode.getLength(); i++) {
50 code = StringFormat.toSafeJavaString(nlCode.item(i).getNodeValue());
51 if(code == null) {
52 code = "";
53 }
54 name = StringFormat.toSafeHTMLString(nlName.item(i).getNodeValue());
55 if(name == null) {
56 name = "";
57 }
58
59 if(code.equals("US")) {
60 s += "<option value=\"" + code + "\">" + name + "</option>";
61 }
62 }
63 }
64 catch(Exception e) {
65 }
66 return s;
67 }
68
69 }
70
71