Hybris-创建新CMS组件

创建Addon扩展

在cmd命令提示符窗口,切换到YOURPATH\bin\platform,使用以下命令从platform的build.xml中运行extgen

ant extgen

输入模板yaddon,输入扩展名(例如:randomimageaddon)和包名de.hybris.platform.addons.randomimageaddon

extgen:
    [input]
    [input] Please choose a template for generation.
    [input] Press [Enter] to use the default value ([yempty], yatddtests, yscala, ygroovy, yacceleratorfulfilmentprocess, merchandisefulfilmentprocess, ychinaacceleratorstorefront, yaddon, ycommercewebservices, ycommercewebservicestest, ycommercewebserviceshmc, ycockpit, ybackoffice)
yaddon
    [input]
    [input] Please choose the name of your extension. It has to start with a letter followed by letters and/or numbers.
    [input] Press [Enter] to use the default value [training]
randomimageaddon
    [input]
    [input] Please choose the package name of your extension. It has to fulfill java package name convention.
    [input] Press [Enter] to use the default value [org.training]
de.hybris.platform.addons.randomimageaddon

上述操作,将在YOURPATH\bin下自动生成如下1个自定义扩展

/custom/randomimageaddon
按照extgen output说明,完成localextensions.xml配置

[echo]
[echo]     Next steps:
[echo]
[echo] 1) Add your extension to your E:\test\hybris\config/localextensions.xml
[echo]
[echo]      <extension dir="E:\test\hybris\bin/custom/randomimageaddon"/>
[echo]
[echo] 2) Please remove all template extensions (again) before you proceed.

[echo]
[echo] 3) Make sure the applicationserver is stopped before you build the extension the first time.
[echo]
[echo] 4) Perform 'ant' in your hybris/platform directory.
[echo]
[echo] 5) Restart the applicationserver
[echo]
[echo]

修改Model定义

在/custom/randomimageaddon/resources/randomimageaddon-items.xml中添加CMS组件定义

修改资源文件/custom/randomimageaddon/resources/localization/randomimageaddon-locales_*.properties

在/custom/randomimageaddon/extensioninfo.xml中添加依赖

注意:完成上述操作之后,需做一次sytem update(勾选Update running system和Localize types即可),将更改推送到数据库,否则hmc中将不能查到该itemtype

定义组件视图

创建视图

/custom/randomimageaddon/acceleratoraddon/web/webroot/WEB-INF/views/desktop/cms/randomimageparagraphcomponent.jsp

定义组件Renderer

为AddOn CMS Component Renderer声明renderer和mapping bean

<bean id="randomImageParagraphComponentRenderer" parent="addOnJspIncludeCMSComponentRenderer" />

<bean id="randomImageParagraphComponentRendererMapping" parent="addonCmsComponentRendererMapping">
        <property name="typeCode" value="RandomImageParagraphComponent" />
        <property name="renderer" ref="randomImageParagraphComponentRenderer" />
</bean>

Build新加组件

使merchandisestorefront可以使用该新加组件,执行以下命令行

ant addoninstall -Daddonnames="randomimageaddon"  -DaddonStorefront.yacceleratorstorefront="merchandisestorefront"

以上命令将会在/custom/merchandise/merchandisestorefront/extensioninfo.xml中添加对randomimageaddon的依赖

<requires-extension name="randomimageaddon"/>

同时在/custom/randomimageaddon/project.properties文件中提供额外的web-spring配置定义

merchandisestorefront.additionalWebSpringConfigs.randomimageaddon=classpath:/randomimageaddon/web/spring/randomimageaddon-web-spring.xml

再者,它还会复制web application content到storefront(需执行ant all命令,执行完成后,可在merchandisestorefront/web/webroot/WEB-INF/views/addons/randomimageaddon/desktop/cms下看到同样的.jsp文件)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值