ZhipSoft.com
              冬去春來
                  鄭重聲明:本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝!!www.ZhipSoft.com
          posts - 94,comments - 149,trackbacks - 0
          ?官方英文版向導(http://struts-menu.sourceforge.net/userguide.html

          一、從1.X升級到2.X需要做以下事情:
          1、改變你的taglib聲明中的URI。
          ?<% at taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %>
          2、改變<plug-in>,使用新的包名"net.sf.navigator." 。
          ?<plug-in className="net.sf.navigator.menu.MenuPlugIn">
          3、改變你的menu-config.xml文件,使用新的包名"net.sf.navigator." 。
          ?<Displayer name="Simple"
          ?? type="net.sf.navigator.displayer.SimpleMenuDisplayer"/>

          二、快速開始:
          1、下載最新的struts-menu版本;
          2、解包到本地目錄;
          3、下載Tomcat或者其它Servlet容器;
          4、把struts-menu.war包放入Tomcat安裝目錄的wabapps目錄下,并重啟Tomcat服務。
          5、打開htpp://localhost:8080/struts-menu/

          三、把Struts Menu整合到你的應用程序中:
          Struts Menu能夠被輕易的整合到你的Struts應用程序中,它也可以整合到一個非Struts的應用程序中,但是我不喜歡這樣做,所以在此沒有提供相應的教程。這里將一步步的帶你整合這個標簽庫。
          你需要把struts-menu.jar放到你的WEB-INF/lib目錄下。然后使用URI標簽聲明你的JSP文件中想使用的這個標簽庫。
          如果使用Struts Menu 2.1,你還需要 Jakarta's Standard Tag Library JAR包放入你的WEB-INF/lib目錄下。下載地址:http://ibiblio.org/maven/taglibs/jars/standard-1.0.4.jar,這個文件包括例程WAR包文件和二進制發布包。
          1、放入struts-menu.jar包到你的應用程序的WEB-INF/lib目錄中。
          2、在你的struts-config.xml文件中加入plug-in設置。
          ?<plug-in className="net.sf.navigator.menu.MenuPlugIn">
          ?? <set-property property="menuConfig"
          ???? value="/WEB-INF/menu-config.xml"/>
          ?</plug-in>

          3、你將需要在你的應用程序的/WEB-INF/menu-config.xml文件中定義你的菜單,這里提供一個簡單的片斷:
          ?<Menu name="contactMenu" title="Contact" location="?Contact">
          ?? <Item name="email" title="E-Mail" location="?EMail"/>
          ?? <Item name="phone" title="Phone" location="?Phone"/>
          ?</Menu>

            更多全面的例程,請查看應用程序的web/WEB-INF目錄中的menu-config.xml文件,你可以截取一段作為你需要的菜單。完整的屬性列表,可以查看MenuBase class's javadocs(http://struts-menu.source......avigator/menu/MenuBase.html)。
          4、在你的JSP文件的頂部加入taglib聲明:
          ?<% at taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %>
          5、在你的JSP文件中要放置菜單的位置加入taglib代碼:
          ?<menu:useMenuDisplayer name="TabbedMenu"
          ?? bundle="org.apache.struts.action.MESSAGE">
          ?? <menu:displayMenu name="Home"/>
          ?? <menu:displayMenu name="About"/>
          ?</menu:useMenuDisplayer>

            屬性name="TabbedMenu"被定義在menu-config.xml文件的頂部:
          ?<Displayer name="TabbedMenu"
          ?? type="net.sf.navigator.displayer.TabbedMenuDisplayer"/>

          (譯注:其實到此步即可在你的JSP文件中添加相應的菜單了,只不過是沒有結合Velocity。在menu-config.xml文件的頭部可以定義多個Displayer,每個Displayer都有name和type屬性,name屬性與JSP文件中menu:useMenuDisplayer標簽的name屬性相對應,即表明使用何種樣式,具體的樣式定義便在type屬性中定義,type屬性中是一個class。在menu-config.xml文件中的菜單定義中的name屬性則與JSP文件中的menu:displayMenu標簽的name屬性相對應。)

          使用定制的Velocity模版實施你的菜單,你需要整合Velocity到你的WEB應用程序中。如果需要這樣做的話,請完成下面的步驟:
          1、確定你的menu-config.xml文件有“Velocity”的displayer定義:
          ?<Displayer name="Velocity"
          ???? type="net.sf.navigator.displayer.VelocityMenuDisplayer"/>

          2、加入Velocity的JARs包到你的WEB-INF/lib目錄中,下載velocity-1.4-rc1.jar(http://www.ibiblio.org/ma......y/jars/velocity-1.4-rc1.jar)和velocity-tools-view-1.0.jar(http://www.ibiblio.org/ma......velocity-tools-view-1.0.jar)。
          3、加入globalMacros.vm(http://cvs.sourceforge.net/viewcvs.py/*checkout*/struts-menu/navigator/web/WEB-INF/classes/globalMacros.vm?content-type=text%2Fplain&rev=1.1(右鍵另存為))到你的WEB-INF/lib目錄中。
          4、改變你的JSP文件中displayer的值為“Velocity”,“config”屬性指向一個文件(如config="/templates/tabs.html")或者如果tabs.htm在你的WEB-INF/classes目錄中的話,則可設config="tabs.html"。

          這里提供了一些使用Velocity的displayer例子,可在sample application(http://demo.raibledesigns.com/struts-menu/index.jsp)中查看。它總是在你的菜單需要的時候顯示CSS,JavaScript和圖像文件。下面有一些在當前的Struts Menu中用到的Velocity模版的例子的鏈接:
          ?CoolMenus: Demo(http://demo.raibledesigns......menu/velocity-coolmenu4.jsp),
          ??  Template(http://struts-menu.sourceforge.net/templates/coolmenus.html
          ?NiceTabs: Demo, Template
          ?Tabs: Demo, Template
          ?XTree: Demo, Template

          所有相關的有用的文件如果你需要的話都可以在下面的站點上下載:
          ?Images (http://struts-menu.sourceforge.net/menu-images/
          ?Stylesheets (http://struts-menu.sourceforge.net/styles/
          ?Scripts (http://struts-menu.sourceforge.net/scripts/
          ?Templates (http://struts-menu.sourceforge.net/templates/

          更多的基于roles的顯示/隱藏菜單的信息,請查看FAQs(http://struts-menu.sourceforge.net/faq.html)。

          四、在Struts之外使用Struts Menu:
          在2.2版中,Menu Repository能夠使用MenuContextListener載入:
          ?<!--
          ??? - Loads the menu-config.xml for struts-menu at startup,
          ??? - by default from "/WEB-INF/menu-config.xml".
          ??? - To override this, add a context-param named "menuConfigLocation"
          ??? - web.xml file.
          ??? -->
          ?<listener>
          ???? <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class>
          ?</listener>

          或者如果你使用Spring,甚至更容易。僅僅需要加入下面的部分到你的applicationContext.xml文件中:
          ?<bean id="menu" class="net.sf.navigator.menu.MenuLoader">
          ?? <property name="menuConfig">
          ???? <value>/WEB-INF/menu-config.xml</value>
          ?? </property>
          ?</bean>
          ?<!-- The menuConfig property is an optional attribute.? It is set to
          ???? /WEB-INF/menu-config.xml by default. -->

          感謝Dan Luputan提供MenuLoader類的源代碼。

          五、從源文件編譯:
          要從源文件編譯這個項目,執行下面的步驟:
          1、下載并安裝Maven(http://maven.apache.org/);
          2、創建一個環境變量MAVEN_HOME指出你的Maven的安裝目錄,然后添加$MAVEN_HOME/bin到你的PATH變量中;
          3、操縱這個目錄你可以擴展源代碼,執行“maven.jar”創建target/struts-menu.jar。

          要展開struts-menu例程,需要下面的步驟:
          1、下載和安裝Tomcat;
          2、創建一個環境變量CATALINA_HOME指出你的Tomcat的安裝目錄;
          3、執行“maven deploy”把應用程序展開到Tomcat中;
          4、打開http://localhost:8080/struts-menu在你喜愛的瀏覽器中。

          如果你喜歡使用Eclipse開發項目,請參考此份開發向導(http://struts-menu.sourceforge.net/devguide.html)。



                  本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
          posted on 2007-03-29 13:40 ZhipSoft 閱讀(315) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 敖汉旗| 桐庐县| 昌乐县| 泰州市| 洛川县| 林甸县| 华坪县| 资阳市| 砚山县| 军事| 宝坻区| 灯塔市| 青阳县| 壶关县| 伊宁市| 千阳县| 东平县| 垣曲县| 略阳县| 大埔县| 聂拉木县| 宜城市| 敦煌市| 蒙山县| 孝义市| 定南县| 鹤庆县| 赤城县| 安吉县| 霍邱县| 荆门市| 马龙县| 庆城县| 子洲县| 和政县| 怀集县| 枝江市| 壶关县| 女性| 彭阳县| 宣威市|