KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > wstore > CheckOutLinkTag


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.wstore;
15 import java.util.*;
16 import java.sql.*;
17 import javax.servlet.*;
18 import javax.servlet.http.*;
19 import javax.servlet.jsp.*;
20 import javax.servlet.jsp.tagext.*;
21
22 import org.apache.ecs.*;
23 import org.apache.ecs.xhtml.*;
24
25 import org.compiere.www.*;
26 import org.compiere.util.*;
27
28 /**
29  * CheckOut Links.
30  * Creates Basket / Checkout Link
31  * <pre>
32  * <cws:checkOutLink/>
33  * </pre>
34  *
35  * @author Jorg Janke
36  * @version $Id: CheckOutLinkTag.java,v 1.8 2003/10/04 03:58:26 jjanke Exp $
37  */

38 public class CheckOutLinkTag extends TagSupport
39 {
40     /** Logger */
41     private Logger log = Logger.getCLogger (getClass());
42     /** One Line */
43     private boolean m_oneLine = false;
44
45     /**
46      * Set to one line
47      * @param var Y or something else
48      */

49     public void setOneLine (String JavaDoc var)
50     {
51         m_oneLine = "Y".equals(var);
52     } // setOneLine
53

54     /**
55      * Start Tag
56      * @return SKIP_BODY
57      * @throws JspException
58      */

59     public int doStartTag() throws JspException
60     {
61         HttpSession session = pageContext.getSession();
62         HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
63         WebBasket wb = (WebBasket)session.getAttribute(WebBasket.NAME);
64
65         log.debug("doStartTag - WebBasket=" + wb);
66         if (wb != null && wb.getLineCount() > 0)
67         {
68             log.debug("doStartTag - WebBasket exists");
69             //
70
JspWriter out = pageContext.getOut();
71             HtmlCode html = new HtmlCode();
72             //
73
if (!m_oneLine)
74                 html.addElement(new hr("90%", "left"));
75             //
76
img img = new img ("basket.gif");
77             img.setBorder(0);
78             a a = new a("basket.jsp");
79             a.setClass("menuMain");
80             if (m_oneLine)
81             {
82                 a.addElement (img);
83                 a.addElement ("Basket");
84             }
85             else
86             {
87                 a.addElement ("Basket");
88                 a.addElement (img);
89             }
90             html.addElement(a);
91             //
92
if (m_oneLine)
93                 html.addElement("&nbsp;- ");
94             else
95                 html.addElement(new br());
96             //
97
img = new img ("checkout.gif");
98             img.setBorder(0);
99             String JavaDoc url = CheckOutServlet.NAME;
100             if (!request.isSecure())
101                 url = "https://" + request.getServerName() + request.getContextPath() + "/" + CheckOutServlet.NAME;
102             a = new a(url);
103             a.setClass("menuMain");
104             a.addElement("Create Order");
105             a.addElement(img);
106             html.addElement(a);
107             //
108
html.output(out);
109         }
110         return (SKIP_BODY);
111     } // doStartTag
112

113     /**
114      * End Tag
115      * @return EVAL_PAGE
116      * @throws JspException
117      */

118     public int doEndTag() throws JspException
119     {
120         return EVAL_PAGE;
121     } // doEndTag
122

123 } // CheckOutLinkTag
124
Popular Tags