0
votes

I'm trying to create a component within an addon. Everything works fine during impex process (contentslot, pagetemplate etc.) but it doesn't get rendered when accessing the page.

I've followed these steps but my controller isn't even get called.

@Controller("ConfirmationComponentController")
@RequestMapping(value = ControllerConstants.Actions.Cms.ConfirmationComponent)
public class ConfirmationComponentController extends AbstractCMSAddOnComponentController<ConfirmationComponentModel> {

  @Override
  protected void fillModel(HttpServletRequest request, Model model, ConfirmationComponentModel component) {

  }
}

I've added the component's jsp in "WEB-INF/views/responsive/cms/.." from the addon module but I keep getting this error:

File [/WEB-INF/views/addons/trainingcore/responsive/cms/confirmationcomponent.jsp] not found

P.S.: I've managed to get the component controller to be called, but the getView() is returning a wrong path and that's why the component is not getting called. Any help? Thank you very much:)

Should this component to be created in addon *-items.xml?

1

1 Answers

2
votes

What you need to know first

Using addons is a complicated endeavor in hybris. You need to know, that the resources are not used in the addon, but they are copied (during build process) to your storefront, where they are used.

All classes in

myaddon/acceleratoraddon/web/src/

will be copied to:

mystorefront/web/addonsrc/myaddon/

All resources in

myaddon/acceleratoraddon/web/webroot/

will be copied to corresponding folders:

mystorefront/web/webroot/WEB-INF/_ui-src/addons/myaddon
mystorefront/web/webroot/WEB-INF/tld/addons/myaddon
mystorefront/web/webroot/WEB-INF/messages/addons/myaddon
mystorefront/web/webroot/WEB-INF/tags/addons/myaddon
mystorefront/web/webroot/WEB-INF/views/addons/myaddon

That means

That means, that the effective path to your component jsp will not be something like:

/WEB-INF/views/cms/...

but will be something like:

/WEB-INF/views/myaddon/cms/...

The path myaddon will depend on the extension your component is declared in. So if you declare it in trainingcore-items.xml it will be

/WEB-INF/views/trainingcore/...

If you declare it in myaddon-items.xml it will be

/WEB-INF/views/myaddon/...