Addon 中的 Hybris 组件不调用控制器
Hybris component in Addon not calling controller
我创建了自定义表单组件。在我将它添加到智能编辑中后,它不会调用控制器来填写表格。
我在 *-items.xml 中创建了 itemtype MyComponentModel,检查了 HAC 部署,它就在那里。
我还添加了这样的注释
@Controller("MyComponentController")
@RequestMapping(value = ControllerConstants.Actions.Cms.MyComponent)
public class MyComponentController extends AbstractAcceleratorCMSComponentController<MyComponentModel> {
并且映射值在我的 ControllerConstants 中,如下所示:
String _Prefix = "/view/"; // NOSONAR
String _Suffix = "Controller"; // NOSONAR
String MyComponent = _Prefix + MyComponentModel._TYPECODE + _Suffix; // NOSONAR
当我在页面上的 smartedit 中添加它时,加载了 .jsp 文件(我可以看到一些文本),但由于未调用控制器
根据 Hybris 文档,我的控制器中调用的方法应该是这样的:
@Override
protected void fillModel(HttpServletRequest request, Model model, MyComponentModel component) {
但是没有调用,所以我无法填写表格。
<div class="span-20 last">
I can see this text
<div class="row item_container_holder">
<c:if test="${not empty MyForm}">
<%--this condition is false, form is empty--%>
注意我也在impex中添加了组件,我在HAC中更新了系统,我尝试同步目录。
INSERT_UPDATE MyComponent; $contentCV[unique = true]; uid[unique = true] ; name ; &componentRef
;; MyComponent ; MyComponent ; MyComponent
编辑:
*-items.xml
<itemtype code="MyComponent" autocreate="true" generate="true" extends="SimpleCMSComponent"
jaloclass="mypackage.b2c.core.jalo.components.MyComponent">
<deployment table="MyComponents" typecode="15900"/>
<attributes>
<attribute qualifier="title" type="localized:java.lang.String">
<persistence type="property" />
<modifiers />
<description>Localized title of the component.</description>
</attribute>
</attributes>
</itemtype>
调用 cms 组件的控制器取决于项目类型。您不能创建 JspIncludeComponent 并期望调用 MyComponent 的组件控制器。
试试这个:
INSERT_UPDATE MyComponent;...
如您所说,您正在尝试在插件中创建此组件
确保您遵循了我提到的步骤
Your comment: I put it on path /WEB-INF/views/responsive/cms
, but I still get an
error Error processing component tag. currentComponent
[MyComponentModel (8796093136412@1)] exception: File
[/WEB-INF/views/responsive/cms/myComponent.jsp] not found
调试 AbstractCMSAddOnComponentController 的 getView 方法以检查路径。
您必须将 jsp 添加到 /youraddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/cms/myComponent.jsp
,稍后将在构建过程中将其复制到您的 stroefront 扩展。
我创建了自定义表单组件。在我将它添加到智能编辑中后,它不会调用控制器来填写表格。
我在 *-items.xml 中创建了 itemtype MyComponentModel,检查了 HAC 部署,它就在那里。
我还添加了这样的注释
@Controller("MyComponentController")
@RequestMapping(value = ControllerConstants.Actions.Cms.MyComponent)
public class MyComponentController extends AbstractAcceleratorCMSComponentController<MyComponentModel> {
并且映射值在我的 ControllerConstants 中,如下所示:
String _Prefix = "/view/"; // NOSONAR
String _Suffix = "Controller"; // NOSONAR
String MyComponent = _Prefix + MyComponentModel._TYPECODE + _Suffix; // NOSONAR
当我在页面上的 smartedit 中添加它时,加载了 .jsp 文件(我可以看到一些文本),但由于未调用控制器
根据 Hybris 文档,我的控制器中调用的方法应该是这样的:
@Override
protected void fillModel(HttpServletRequest request, Model model, MyComponentModel component) {
但是没有调用,所以我无法填写表格。
<div class="span-20 last">
I can see this text
<div class="row item_container_holder">
<c:if test="${not empty MyForm}">
<%--this condition is false, form is empty--%>
注意我也在impex中添加了组件,我在HAC中更新了系统,我尝试同步目录。
INSERT_UPDATE MyComponent; $contentCV[unique = true]; uid[unique = true] ; name ; &componentRef
;; MyComponent ; MyComponent ; MyComponent
编辑:
*-items.xml
<itemtype code="MyComponent" autocreate="true" generate="true" extends="SimpleCMSComponent"
jaloclass="mypackage.b2c.core.jalo.components.MyComponent">
<deployment table="MyComponents" typecode="15900"/>
<attributes>
<attribute qualifier="title" type="localized:java.lang.String">
<persistence type="property" />
<modifiers />
<description>Localized title of the component.</description>
</attribute>
</attributes>
</itemtype>
调用 cms 组件的控制器取决于项目类型。您不能创建 JspIncludeComponent 并期望调用 MyComponent 的组件控制器。
试试这个:
INSERT_UPDATE MyComponent;...
如您所说,您正在尝试在插件中创建此组件
确保您遵循了我提到的步骤
Your comment: I put it on path
/WEB-INF/views/responsive/cms
, but I still get an error Error processing component tag. currentComponent [MyComponentModel (8796093136412@1)] exception:File [/WEB-INF/views/responsive/cms/myComponent.jsp] not found
调试 AbstractCMSAddOnComponentController 的 getView 方法以检查路径。
您必须将 jsp 添加到 /youraddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/cms/myComponent.jsp
,稍后将在构建过程中将其复制到您的 stroefront 扩展。