ofbiz实战3——创建booking项目首页

来源:互联网 发布:java unix时间戳 编辑:程序博客网 时间:2024/05/14 12:34

首页内容暂时显示一个hello world,主要把菜单等显示通过main-decorator配置好。界面如下:


实现步骤:

1. 配置controller.xml文件

点击应用进入后默认uri是"main",所以在controller.xml文件中配置main映射:

<request-map uri="main"><security https="true" auth="true"/><response name="success" type="view" value="main"/></request-map><view-map name="main" type="screen" page="component://booking/widget/booking/BookingScreens.xml#main"/>

2. 配置BookingScreens.xml#main

创建文件component://booking/widget/booking/BookingScreens.xml#main

<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns="http://ofbiz.apache.org/Widget-Screen" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">   <screen name="main">        <section>            <actions>                 <!--<set field="headerItem" value="TermManange"/>-->                <set field="headerItem" value="main"/>            </actions>            <widgets>                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">                    <decorator-section name="body">                        <label>hello world</label>                    </decorator-section>                </decorator-screen>            </widgets>        </section>    </screen></screens>


关于headerItem参数是在apache-ofbiz-16.11.02\themes\tomahawk\template\AppBarClose.ftl中有使用到。表示三级菜单的name。

如果设置为TermManange,那么点击应用进入首页会显示3级菜单“学期管理”,具体界面效果如下:

此时body内容可以引用termManange的,但这里暂时配置hello world,所以前面的headerItem也不能设置为TermManange,可以设置为main。

3. 配置CommonScreens.xml#main-decorator

${parameters.mainDecoratorLocation}这个应该是web.xml里面配置了mainDecoratorLocation参数,其值是component://booking/widget/booking/CommonScreens.xml

所以创建文件component://booking/widget/booking/CommonScreens.xml

<?xml version="1.0" encoding="UTF-8"?><screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns="http://ofbiz.apache.org/Widget-Screen" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">    <screen name="main-decorator">        <section>            <actions>                <!-- base/top/specific map first, then more common map added for shared labels -->                <property-map resource="BookingUiLabels" map-name="uiLabelMap" global="true"/>                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>                <set field="layoutSettings.companyName" from-field="uiLabelMap.BookingCompanyName" global="true"/>                <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.BookingCompanySubtitle" global="true"/>                  <set field="activeApp" value="booking" global="true"/>                <set field="applicationMenuName" value="BookingAppBar" global="true"/>                <set field="applicationMenuLocation" value="component://booking/widget/booking/BookingMenus.xml" global="true"/>                <set field="applicationTitle" value="${uiLabelMap.BookingApplication}" global="true"/>            </actions>            <widgets>                <section>                    <condition>                        <if-has-permission permission="BOOKING" action="_VIEW"/>                    </condition>                    <actions>                        <!-- <set field="layoutSettings.javaScripts[]" value="/example/js/ExamplePushNotifications.js" global="true"/>-->                    </actions>                </section>                <include-screen name="ApplicationDecorator" location="component://commonext/widget/CommonScreens.xml"/>            </widgets>        </section>    </screen></screens>

applicationMenuName参数:表示菜单使用的菜单栏名称。
applicationMenuLocation参数:表示菜单配置文件路径。

applicationTitle参数:表示应用标题,这个标题暂时不知道哪里会用到,二级菜单和浏览器title都没有用到。

layoutSettings.companyName参数:这个标题应该是用到浏览器标题的。因为没配置国际化是页签标题是下面这个样子:


配置BookingUiLabels.xml后:


其他的参数暂时先不用管。

原创粉丝点击