KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > web > renderers > LoginRenderer


1 package com.genimen.djeneric.web.renderers;
2
3 import javax.xml.parsers.FactoryConfigurationError JavaDoc;
4 import javax.xml.parsers.ParserConfigurationException JavaDoc;
5
6 import org.w3c.dom.CDATASection JavaDoc;
7 import org.w3c.dom.Document JavaDoc;
8 import org.w3c.dom.Element JavaDoc;
9
10 import com.genimen.djeneric.repository.exceptions.DjenericException;
11 import com.genimen.djeneric.web.util.DjenericSessionManager;
12
13 public class LoginRenderer extends AbstractRenderer
14 {
15   public LoginRenderer()
16   {
17   }
18
19   public Document JavaDoc asXml(DjenericSessionManager sessionManager, String JavaDoc message) throws FactoryConfigurationError JavaDoc,
20       ParserConfigurationException JavaDoc, DjenericException
21   {
22     Document JavaDoc doc = createDocument();
23     Element JavaDoc root = doc.createElement("login");
24     doc.appendChild(root);
25
26     Element JavaDoc userid = doc.createElement("userid");
27     if (sessionManager.getUserId() != null) userid.setAttribute("value", sessionManager.getUserId());
28     Element JavaDoc password = doc.createElement("password");
29
30     if (message != null)
31     {
32       Element JavaDoc msg = doc.createElement("message");
33       CDATASection JavaDoc msgvalue = doc.createCDATASection(message);
34       msg.appendChild(msgvalue);
35       root.appendChild(msg);
36     }
37
38     root.appendChild(userid);
39     root.appendChild(password);
40
41     return doc;
42   }
43
44 }
45
Popular Tags