1 package com.genimen.djeneric.web.renderers; 2 3 import javax.xml.parsers.FactoryConfigurationError ; 4 import javax.xml.parsers.ParserConfigurationException ; 5 6 import org.w3c.dom.CDATASection ; 7 import org.w3c.dom.Document ; 8 import org.w3c.dom.Element ; 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 asXml(DjenericSessionManager sessionManager, String message) throws FactoryConfigurationError , 20 ParserConfigurationException , DjenericException 21 { 22 Document doc = createDocument(); 23 Element root = doc.createElement("login"); 24 doc.appendChild(root); 25 26 Element userid = doc.createElement("userid"); 27 if (sessionManager.getUserId() != null) userid.setAttribute("value", sessionManager.getUserId()); 28 Element password = doc.createElement("password"); 29 30 if (message != null) 31 { 32 Element msg = doc.createElement("message"); 33 CDATASection 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 |