KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > widget > html > HtmlMenuWrapperImage


1 /*
2  * $Id: HtmlMenuWrapperImage.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.widget.html;
25
26 import java.io.IOException JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Map JavaDoc;
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32 import javax.servlet.http.HttpServletResponse JavaDoc;
33 import javax.xml.parsers.ParserConfigurationException JavaDoc;
34
35 import org.ofbiz.base.util.UtilMisc;
36 import org.ofbiz.widget.menu.MenuStringRenderer;
37 import org.ofbiz.widget.menu.ModelMenuItem;
38 import org.ofbiz.entity.GenericDelegator;
39 import org.ofbiz.entity.GenericEntityException;
40 import org.ofbiz.entity.GenericValue;
41
42 import org.xml.sax.SAXException JavaDoc;
43
44 /**
45  * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu
46  *
47  * @author <a HREF="mailto:byersa@automationgroups.com">Al Byers</a>
48  * @version $Rev: 5462 $
49  * @since 3.0
50  */

51 public class HtmlMenuWrapperImage extends HtmlMenuWrapper {
52     
53     public static final String JavaDoc module = HtmlMenuWrapperImage.class.getName();
54
55     protected HtmlMenuWrapperImage() {}
56
57     public HtmlMenuWrapperImage(String JavaDoc resourceName, String JavaDoc menuName, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
58             throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
59         super(resourceName, menuName, request, response);
60     }
61
62     public MenuStringRenderer getMenuRenderer() {
63         return new HtmlMenuRendererImage(request, response);
64     }
65     
66     public void init(String JavaDoc resourceName, String JavaDoc menuName, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
67             throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
68         
69         super.init(resourceName, menuName, request, response);
70         String JavaDoc pubPt = (String JavaDoc)request.getAttribute("pubPt");
71         //if (Debug.infoOn()) Debug.logInfo("in init, pubPt:" + pubPt, module);
72
Map JavaDoc dummyMap = new HashMap JavaDoc();
73         GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
74         //if (Debug.infoOn()) Debug.logInfo("in init, delegator:" + delegator, module);
75
try {
76             List JavaDoc menuItemList = modelMenu.getMenuItemList();
77             Iterator JavaDoc iter = menuItemList.iterator();
78             while (iter.hasNext()) {
79                ModelMenuItem menuItem = (ModelMenuItem)iter.next();
80                String JavaDoc contentId = menuItem.getAssociatedContentId(dummyMap);
81                //if (Debug.infoOn()) Debug.logInfo("in init, contentId:" + contentId, module);
82
GenericValue webSitePublishPoint = delegator.findByPrimaryKeyCache("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId));
83                String JavaDoc menuItemName = menuItem.getName();
84                //if (Debug.infoOn()) Debug.logInfo("in init, menuItemName:" + menuItemName, module);
85
//if (Debug.infoOn()) Debug.logInfo("in init, webSitePublishPoint:" + webSitePublishPoint, module);
86
putInContext(menuItemName, "WebSitePublishPoint", webSitePublishPoint);
87             }
88         } catch (GenericEntityException e) {
89             return;
90         }
91     }
92 }
93
Popular Tags