Ofbiz:创建一个组件

来自WHY42

创建组件

已经ant load-demo并能跑起来之后,可以尝试创建一个新的应用。

ant create-component

可能是下面这样的输出:都输入hello好了:

Buildfile: /Users/UserName/sandbox/ofbiz1307/build.xml
 create-component:
 [input] Component name: (e.g. mycomponent) [Mandatory]
hello
 [input] Component resource name: (e.g. MyComponent) [Mandatory]
hello
 [input] Webapp name: (e.g. mycomponent) [Mandatory]
hello
 [input] Base permission: (e.g. MYCOMPONENT) [Mandatory]
HELLO
 [echo] The following hot-deploy component will be created:
 [echo] Name: hello
 [echo] Resource Name: hello
 [echo] Webapp Name: hello
 [echo] Base permission: HELLO
 [echo] Folder: /Users/UserName/sandbox/ofbiz1307/hot-deploy/ofbizdemo
 [echo]
 [input] Confirm: (Y, [N], y, n)
y

创建完了,刷新下eclipse,可以在hot-deploy中看到刚才创建的组件。然后,加点什么信息吧,好像这样就是我们做的了。找到hello/widget/helloScreens.xml,在body的部分中间加入点信息吧:

<decorator-section name="body">
    <label text="hello riguz!"/>
</decorator-section>

OK,启动ofbiz,登录我们创建的组件:

呀,提示登录?登录不进去?别急,继续看。

权限配置

刚才创建组件的时候,我们设置了权限为HELLO,然后可以看到ofbiz-component.xml中有这样的信息:

 <webapp name="hello"
        title="hello"
        server="default-server"
        location="webapp/hello"
        base-permission="OFBTOOLS,HELLO"
        mount-point="/hello"/>

以及CommonScreens.xml中有:

<condition>
    <if-has-permission permission="HELLO" action="_VIEW"/>
</condition>

这样其实我们定义了一个新的权限HELLO。可以删掉这个试试。在菜单中找到团体->安全,然后找到admin用户所属的安全组(查找用户登录->选择admin->选择安全组->选择FULLADMIN),然后看看这个安全组的权限,添加一个HELLO_VIEW的权限:

然后再访问就好了: