KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > javaee > blueprints > components > ui > example > CompBBean


1 /*
2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
3 * http://developer.sun.com/berkeley_license.html
4 * $Id: CompBBean.java,v 1.2 2006/06/23 17:05:41 basler Exp $
5 */

6 package com.sun.javaee.blueprints.components.ui.example;
7
8 import java.io.IOException JavaDoc;
9 import javax.faces.event.PhaseEvent;
10 import javax.faces.context.FacesContext;
11 import javax.servlet.http.HttpServletResponse JavaDoc;
12
13 /*
14  * CompBBean.java
15  *
16  * Created on June 15, 2006, 8:22 AM
17  *
18  * To change this template, choose Tools | Template Manager
19  * and open the template in the editor.
20  */

21
22 /**
23  *
24  * @author basler
25  */

26 public class CompBBean {
27     
28     private String JavaDoc itemId="This is one test";
29     private static final boolean bDebug=false;
30     
31     /** Creates a new instance of Comp1Bean */
32     public CompBBean() {
33     }
34     
35     public void processMethod(PhaseEvent event) {
36         HttpServletResponse JavaDoc response=null;
37         try {
38             FacesContext context=event.getFacesContext();
39             response=(HttpServletResponse JavaDoc)context.getExternalContext().getResponse();
40             StringBuffer JavaDoc sb=new StringBuffer JavaDoc();
41             response.setContentType("text/xml;charset=UTF-8");
42             response.setStatus(200);
43             // need to set no cache or IE will not make future requests when same URL used.
44
response.setHeader("Pragma", "No-Cache");
45             response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
46             response.setDateHeader("Expires", 1);
47             sb.append("<response>");
48             
49             if(itemId.indexOf("test1") > -1) {
50                 sb.append("<title><![CDATA[" + itemId + " Lookup]]></title>");
51                 sb.append("<message><![CDATA[<b>The itemId that is performing this lookup is '" + itemId +
52                         "'.</b><br/><br/>This popup is trigger through the onmouseover and onmouseout event handlers. " +
53                         "This popup request is fulfilled using a <b>JSF managed bean</b>, that is called by the CompBPhaselistener]]></message>");
54             } else {
55                 sb.append("<title><![CDATA[" + itemId + " Lookup]]></title>");
56                 sb.append("<message><![CDATA[<b>The itemId that is performing this lookup is '" + itemId +
57                         "'.</b><br/><br/>This popup is trigger through the onmouseover event handler and hidden when the user clicks on the 'CLOSE' link in the popup." +
58                         "This popup request is fulfilled using a <b>JSF managed bean</b>, that is called by the CompBPhaselistener" +
59                         "<br/><br/><span onclick=\"bpui.compB.hidePopup('pop1')\" style=\"z-index: 4; position: relative; cursor: pointer\"><b>[<u>CLOSE</u>]</b></span>" +
60                         "]]></message>");
61             }
62             
63             
64             
65             sb.append("</response>");
66             if(bDebug) System.out.println("processMethod final = " + sb);
67             response.getWriter().write(sb.toString());
68         } catch (IOException JavaDoc iox) {
69             iox.printStackTrace();
70         } finally {
71             try {
72                 response.getWriter().flush();
73             } catch (Exception JavaDoc ee) {}
74             event.getFacesContext().responseComplete();
75         }
76         
77     }
78     
79     public void setItemId(String JavaDoc id) {
80         this.itemId=id;
81     }
82     public String JavaDoc getItemId() {
83         return itemId;
84     }
85     
86 }
87
Popular Tags