KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > presentation > NewSitePresentation


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.snapper.presentation;
9
10
11
12 // Enhydra SuperServlet specification imports
13
import org.enhydra.snapper.presentation.html.*;
14 import org.enhydra.snapper.spec.*;
15 import org.enhydra.xml.xmlc.XMLObject;
16 import org.w3c.dom.Node JavaDoc;
17 import org.w3c.dom.html.HTMLOptionElement;
18
19
20 public class NewSitePresentation extends BasePO {
21
22
23       protected XMLObject getDOM() throws Exception JavaDoc {
24
25         NewSiteHTML newSite;
26         Language[] list;
27         HTMLOptionElement templateOption;
28
29         newSite = (NewSiteHTML)comms.xmlcFactory.create(NewSiteHTML.class);
30         
31         if (comms.request.getParameter("err") != null) {
32             //newSite.setTextErr("Could not create site! Name, Language, Max.Size and Max.Age are required fields!");
33

34         }
35         
36
37         try{
38             LanguageList ll = LanguageListFactory.createLanguageList("org.enhydra.snapper.business.LanguageListImpl");
39             list = ll.getList(dbTransaction);
40         
41             templateOption = newSite.getElementTemplateLanguage();
42             Node JavaDoc languageSelect = templateOption.getParentNode();
43             templateOption.removeAttribute("id");
44             templateOption.removeChild(templateOption.getFirstChild());
45             for (int numLanguages = 0; numLanguages < list.length; numLanguages++) {
46     
47                     Language currentLanguage = list[numLanguages];
48                     HTMLOptionElement clonedOption = (HTMLOptionElement) templateOption.cloneNode(true);
49                     clonedOption.setValue(currentLanguage.getHandle());
50                     Node JavaDoc optionTextNode = clonedOption.getOwnerDocument().
51                         createTextNode(currentLanguage.getName());
52                     clonedOption.appendChild(optionTextNode);
53                     // Do only a shallow copy of the option as we don't want the text child
54
// of the node option
55
languageSelect.appendChild(clonedOption);
56                 }
57         
58         templateOption.getParentNode().removeChild(templateOption);
59         }
60                 catch(Exception JavaDoc ex) {
61                    System.out.print(ex.toString());}
62         
63
64         return newSite;
65     }
66
67 }
68
Popular Tags