1 19 20 package xalanDoc.presentation; 21 22 28 30 import org.w3c.dom.*; 31 import org.w3c.dom.html.*; 32 33 import com.lutris.appserver.server.httpPresentation.*; 34 import com.lutris.appserver.server.user.User; 35 36 import javax.xml.transform.stream.StreamSource ; 38 import javax.xml.transform.dom.DOMResult ; 39 import javax.xml.transform.TransformerFactory ; 40 import javax.xml.transform.Transformer ; 41 import xalanDoc.XalanDoc; 42 43 import xalanDoc.spec.*; 44 45 public class ContactList implements HttpPresentation { 46 47 public void run(HttpPresentationComms comms) 48 throws HttpPresentationException { 49 50 ContactListHTML page = (ContactListHTML) 52 comms.xmlcFactory.create(ContactListHTML.class); 53 54 User user = comms.session.getUser(); 56 57 String username; 59 if (user != null) { 60 username = user.getName(); 61 } else { 62 username = "Enhydra User"; 63 } 64 65 page.setTextUsername(username); 67 68 try { 69 String dir= XalanDoc.getContactsDir(); 70 71 Manager manager = ManagerFactory.getManager("xalanDoc.business.ManagerImpl"); 72 manager.transform(dir,new DOMResult (page.getElementContactList())); 73 74 78 }catch(NullPointerException e){ 79 80 } catch (Exception e) { 81 e.printStackTrace(); 82 try { 83 writeError("Couldn't process XSL", comms); 84 } catch (java.io.IOException ioe) { 85 ioe.printStackTrace(); 86 } 87 return; 88 } 89 90 comms.response.writeDOM(page); 92 } 93 94 private void writeError(String msg, HttpPresentationComms comms) 95 throws HttpPresentationException, java.io.IOException { 96 comms.response.setContentType("text/plain"); 97 comms.response.getOutputStream().print(msg); 98 } 99 } 100 | Popular Tags |