01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18:
19: package org.apache.roller.ui.rendering.model;
20:
21: import java.util.Map;
22: import javax.servlet.jsp.PageContext;
23: import org.apache.commons.logging.Log;
24: import org.apache.commons.logging.LogFactory;
25: import org.apache.roller.RollerException;
26: import org.apache.roller.ui.core.tags.menu.EditorNavigationBarTag;
27:
28: /**
29: * Model which provides methods for displaying editor menu/navigation-bar.
30: *
31: * Implemented by calling hybrid JSP tag.
32: */
33: public class MenuModel implements Model {
34:
35: private static Log logger = LogFactory.getLog(MenuModel.class);
36:
37: private PageContext pageContext = null;
38:
39: /** Template context name to be used for model */
40: public String getModelName() {
41: return "menuModel";
42: }
43:
44: /** Init page model based on request */
45: public void init(Map initData) throws RollerException {
46:
47: // extract page context
48: this .pageContext = (PageContext) initData.get("pageContext");
49: }
50:
51: /**
52: * Display author menu.
53: * @param vertical True for vertical navbar.
54: * @return String HTML for navbar.
55: */
56: public String showAuthorMenu(boolean vertical) {
57: EditorNavigationBarTag editorTag = new EditorNavigationBarTag();
58: editorTag.setPageContext(pageContext);
59: if (vertical) {
60: editorTag.setView("templates/navbar/navbar-vertical.vm");
61: } else {
62: editorTag.setView("templates/navbar/navbar-horizontal.vm");
63: }
64: editorTag.setModel("editor-menu.xml");
65: return editorTag.emit();
66: }
67:
68: }
|