KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xalanDoc > presentation > ContactList


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: ContactList.java,v 1.2 2005/01/17 14:03:39 slobodan Exp $
18  */

19
20 package xalanDoc.presentation;
21
22 //import org.apache.xalan.xslt.XSLTProcessor;
23
//import org.apache.xalan.xslt.XSLTInputSource;
24
//import org.apache.xalan.xslt.XSLTResultTarget;
25
//import org.apache.xalan.xslt.XSLTProcessorFactory;
26
//import org.apache.xalan.xslt.StylesheetRoot;
27

28 //import org.apache.xalan.xpath.xdom.XercesLiaison;
29

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 //Slobodan Vujasinovic
37
import javax.xml.transform.stream.StreamSource JavaDoc;
38 import javax.xml.transform.dom.DOMResult JavaDoc;
39 import javax.xml.transform.TransformerFactory JavaDoc;
40 import javax.xml.transform.Transformer JavaDoc;
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         // Instantiate the page
51
ContactListHTML page = (ContactListHTML)
52             comms.xmlcFactory.create(ContactListHTML.class);
53
54         // Get the user from session
55
User user = comms.session.getUser();
56
57         // Figure out the username
58
String JavaDoc username;
59         if (user != null) {
60             username = user.getName();
61         } else {
62             username = "Enhydra User";
63         }
64         
65         // set the name of the username, using an XMLC convenience method
66
page.setTextUsername(username);
67
68         try {
69          String JavaDoc dir= XalanDoc.getContactsDir();
70
71          Manager manager = ManagerFactory.getManager("xalanDoc.business.ManagerImpl");
72          manager.transform(dir,new DOMResult JavaDoc(page.getElementContactList()));
73
74 /*
75  *You cannot create instances of classes from business layer when start xalanDoc_pres
76  *Catch NullPointerException , response will be default HTML page
77  */

78         }catch(NullPointerException JavaDoc e){
79            
80         } catch (Exception JavaDoc e) {
81             e.printStackTrace();
82         try {
83             writeError("Couldn't process XSL", comms);
84         } catch (java.io.IOException JavaDoc ioe) {
85               ioe.printStackTrace();
86         }
87             return;
88         }
89
90         // Write the page
91
comms.response.writeDOM(page);
92     }
93
94     private void writeError(String JavaDoc msg, HttpPresentationComms comms)
95         throws HttpPresentationException, java.io.IOException JavaDoc {
96         comms.response.setContentType("text/plain");
97         comms.response.getOutputStream().print(msg);
98     }
99 }
100
Popular Tags