moqui 学习笔记1

学习moqui 我先从Screen 入手

 

moqui screen 不同于ofbiz screen 机制,在ofbiz中screen 只是负责页面的生成,只是众多请求类型中的一种,而moqui 的screen 则是处理所有请求的地方,就相当于ofbiz 中的controller一样。

 

在moqui 中 screen 负责了整个 controller 的内容,页面渲染部分 使用 widget,与业务整合 使用transition。

请求地址代表了你要调用那一个screen 处理。

screen 地址不同于ofbiz 使用component指定等方式,这个地址可以不写,当不指定地址的时候默认去查找当前screen同级的并且同名称的文件夹下的screen xml 文件,例如:

ExampleApp.xml定义了一个screen

<subscreens default-item="Example"> //指定默认screen 位置为 ExampleApp/Example.xml

        <subscreens-item name="ExamplePolicies" menu-index="4" menu-title="Policies"/>

        //位置为 ExampleApp/ExamplePolicies.xml

        <subscreens-item name="ExampleTerms" menu-index="5" menu-title="Terms"/>

        //位置为 ExampleApp/ExampleTerms.xml

        <subscreens-item name="ExampleWiki" menu-index="6" menu-title="Wiki"/>

        //位置为 ExampleApp/ExampleWiki.xml

        <subscreens-item name="ExampleMarkdown" menu-index="7" menu-title="Markdown"/>

    </subscreens>

当然如果你需要指定位置 也可以使用location属性

<subscreens-item name="ExamplePolicies" menu-index="4" menu-title="Policies" location="component://XXXXXXXXXX"/>

 

moqui screen 调用的起始文件是 webroot/screen/webroot.xml 

这个定义位置可以修改,修改位置在 各种moquiXXXconf.xml  默认位置是 runtime/conf/MoquiDevConf.xml

config 文件定义了moqui 运行的所有配置项,而且可以有多个,用于不同情况使用不同配置

配置文件 conf 中 有一条属性:

<root-screen host=".*" location="component://webroot/screen/webroot.xml"/> 定义了请求入口文件

 

这个webroot.xml 中定义了其他模块的入口文件

<subscreens default-item="apps">

        <!-- if the client is an iPad, default to the ipad subscreens item instead of apps, but allow either to be used explicitly -->

        <!-- <conditional-default condition="(ec.web.request.getHeader('User-Agent')?:'').matches('.*iPad.*')" item="ipad"/> -->

 

        <!-- refer to the UNDECORATED (or self-decorating) app roots here -->

    </subscreens>

由于我们知道 apps没有写路径 location  那么它的位置为 webroot/apps.xml文件 也就是所模块的统一入口就是它了。

打开apps.xml 里面有一项

 

 <subscreens default-item="example">

        <!-- refer to the various app roots here -->

        <subscreens-item name="example" location="component://example/screen/ExampleApp.xml"

                         menu-title="Example" menu-index="8"/>

        <subscreens-item name="tools" location="component://tools/screen/Tools.xml"

                         menu-title="Tools" menu-index="9"/>

        <subscreens-item name="system" menu-title="system" location="component://system/screen/system.xml"/>

    </subscreens>

这里是把所有模块入口加载进来的的地方,所以在moqui 教程中 添加模块需要在这个文件中添加一项

红色字体就是我添加的新component入口

 

moqui screen 没有使用ofbiz 的decorator设计模式,它的很多设计模式都发生了改变, 据我了解entity使用了facade 设计模式。在上面我们看到页面的层级嵌套 使用了subscreens 标签,这里的subscreens 是为了实现导航的页面跳转,如果点击页面跳转呢?

 

在moqui screen 中有transition 标签,这个标签负责了大部分的业务处理工作 服务的调用,页面的流转,请求的处理等等等。。。。。

所以点击事件跳转可以在当前screen 中进行处理,有点像一个页面就对应一个controller。暂时还不知道这样做有没有原来ofbiz 把controller 集中处理好,需要在实际应用中检验看看,希望因为到处放处理请求的transition 太乱发晕,但是如果有计划的把通用的transition 放在合适的地方,moqui screen 这种方式肯定比ofbiz 更加直观,更加方便。(终于不用像ofbiz 一样一个文件跳到另一个文件了)。

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值