KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > pim > presentation > enhydrapim > Find


1 /*
2  * Created on May 6, 2005
3  *
4  * TODO To change the template for this generated file go to Window -
5  * Preferences - Java - Code Style - Code Templates
6  */

7 package org.enhydra.pim.presentation.enhydrapim;
8
9 import java.util.Vector JavaDoc;
10
11 import org.enhydra.pim.business.api.ContactTypeI;
12 import org.enhydra.pim.presentation.BasePO;
13 import org.enhydra.pim.spec.ContactTypeManagerFactory;
14 import org.enhydra.xml.xmlc.XMLObject;
15 import org.w3c.dom.Node JavaDoc;
16 import org.w3c.dom.html.HTMLOptionElement;
17
18 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
19
20 /**
21  * @author P.Djojic May 6, 2005 1:26:04 AM
22  *
23  * TODO Find
24  */

25 public class Find extends BasePO {
26
27     public static final String JavaDoc FIRSTNAME = "firstname";
28
29     public static final String JavaDoc LASTNAME = "lastname";
30
31     public static final String JavaDoc NICKNAME = "nickname";
32
33     public static final String JavaDoc CONTACTTYPE = "contacttype";
34
35     public static final String JavaDoc ID_CONTACTTYPE = "contactType";
36
37     public static final String JavaDoc ID_CONTACTTYPEVALUE = "contactTypeValue";
38
39     public static final String JavaDoc CONTACTDATA = "contactdata";
40
41     /*
42      * (non-Javadoc)
43      *
44      * @see org.enhydra.pim.presentation.BasePO#handleDefault()
45      */

46
47     public XMLObject handleDefault() throws HttpPresentationException {
48         FindHTML page = (FindHTML) myComms.xmlcFactory.create(FindHTML.class);
49         try {
50
51             // Generate the person's Disc list and create the HTML template
52
// references
53

54             HTMLOptionElement selectRow = page.getElementContactTypeValue();
55             Node JavaDoc selectField = selectRow.getParentNode();
56
57             // Remove ids to prevent duplicates
58

59             selectRow.removeAttribute("id");
60
61             selectRow.setAttribute("value", "");
62             selectRow.getFirstChild().setNodeValue("");
63             selectField.appendChild(selectRow.cloneNode(true));
64
65             Vector JavaDoc selectItems = ContactTypeManagerFactory.getContactTypeManager().getContactTypes();
66             for (int i = 0; i < selectItems.size(); i++) {
67                 ContactTypeI cType = (ContactTypeI) selectItems.elementAt(i);
68                 selectRow.setAttribute("value", cType.getContact_type());
69                 selectRow.getFirstChild().setNodeValue(cType.getContact_type());
70                 Node JavaDoc clonedRow = selectRow.cloneNode(true);
71                 selectField.appendChild(clonedRow);
72             }
73
74             // Finally remove the template row and template select option
75
// from the page
76
selectRow.getParentNode().removeChild(selectRow);
77         } catch (Exception JavaDoc ex) {
78             return showErrorPage("Error during Find:" + ex.getMessage());
79         }
80         // write out HTML
81
return page;
82     }
83
84     /*
85      * (non-Javadoc)
86      *
87      * @see org.enhydra.pim.presentation.BasePO#loggedInUserRequired()
88      */

89     protected boolean loggedInUserRequired() {
90         // TODO Auto-generated method stub
91
return true;
92     }
93
94 }
Popular Tags