01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.widget.html;
19:
20: import java.io.IOException;
21: import java.util.HashMap;
22: import java.util.Iterator;
23: import java.util.List;
24: import java.util.Map;
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27: import javax.xml.parsers.ParserConfigurationException;
28:
29: import org.ofbiz.base.util.UtilMisc;
30: import org.ofbiz.widget.menu.MenuStringRenderer;
31: import org.ofbiz.widget.menu.ModelMenuItem;
32: import org.ofbiz.entity.GenericDelegator;
33: import org.ofbiz.entity.GenericEntityException;
34: import org.ofbiz.entity.GenericValue;
35:
36: import org.xml.sax.SAXException;
37:
38: /**
39: * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu
40: */
41: public class HtmlMenuWrapperImage extends HtmlMenuWrapper {
42:
43: public static final String module = HtmlMenuWrapperImage.class
44: .getName();
45:
46: protected HtmlMenuWrapperImage() {
47: }
48:
49: public HtmlMenuWrapperImage(String resourceName, String menuName,
50: HttpServletRequest request, HttpServletResponse response)
51: throws IOException, SAXException,
52: ParserConfigurationException {
53: super (resourceName, menuName, request, response);
54: }
55:
56: public MenuStringRenderer getMenuRenderer() {
57: return new HtmlMenuRendererImage(request, response);
58: }
59:
60: public void init(String resourceName, String menuName,
61: HttpServletRequest request, HttpServletResponse response)
62: throws IOException, SAXException,
63: ParserConfigurationException {
64:
65: super .init(resourceName, menuName, request, response);
66: String pubPt = (String) request.getAttribute("pubPt");
67: //if (Debug.infoOn()) Debug.logInfo("in init, pubPt:" + pubPt, module);
68: Map dummyMap = new HashMap();
69: GenericDelegator delegator = (GenericDelegator) request
70: .getAttribute("delegator");
71: //if (Debug.infoOn()) Debug.logInfo("in init, delegator:" + delegator, module);
72: try {
73: List menuItemList = modelMenu.getMenuItemList();
74: Iterator iter = menuItemList.iterator();
75: while (iter.hasNext()) {
76: ModelMenuItem menuItem = (ModelMenuItem) iter.next();
77: String contentId = menuItem
78: .getAssociatedContentId(dummyMap);
79: //if (Debug.infoOn()) Debug.logInfo("in init, contentId:" + contentId, module);
80: GenericValue webSitePublishPoint = delegator
81: .findByPrimaryKeyCache("WebSitePublishPoint",
82: UtilMisc.toMap("contentId", contentId));
83: String 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",
87: webSitePublishPoint);
88: }
89: } catch (GenericEntityException e) {
90: return;
91: }
92: }
93: }
|