cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Custom addon controller ignored

Former Member
0 Likes
1,794

In order to modify a jsp from the commerceorgaddon I had to modify the UserManagementPageController defined in the same hybris addon.

To resolve this problem, I created a new addon wich depends on commerceorgaddon. In my newaddon I copied the UserManagementPageController and made my changes there (also I put there my new jsp). Finally I define in the web-spring.xml of my addon the following:

     <alias alias="userManagementPageController" name="customUserManagementPageController"/>
     <bean name="customUserManagementPageController" class="de.hybris.platform.commerceorgaddon.controllers.pages.UserManagementPageController"/>
 
 <!-- add the url to controller mapping to the existing SimpleUrlHandlerMapping bean -->
 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
     <property name="mappings">
         <props>
             <prop key="/my-company/organization-management/manage-users/**">customUserManagementPageController</prop>
         </props>
     </property>
 </bean>

The problem is that when I go to my storefront the UserManagementPageController being used is the the one defined in the commerceorgaddon and not the one that I customized in my new addon.

Any idea how can I do to use my new controller?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member

Hi Martin,

Please make sure you have placed the Controller in the correct folder. The controller should be placed in acceleratoraddon>web>src>[package]>controllers. The Jsp should be placed in acceleratoraddon>web>webroot>WEB-INF>views.

Once you make sure the files are in correct location. You need to run ant addonuninstall command to uninstall OTB commerceorgaddon ant addonuninstall -Daddonnames="commerceorgaddon" -DaddonStorefront.yacceleratorstorefront="<storefrontName>". Then run ant clean all once the build is successful check if the files are removed. You then need to run ant addoninstall -Daddonnames="customcommerceorgaddon" -DaddonStorefront.yacceleratorstorefront="<storefrontName>" to install your custom addon to the storefront. Once done you need to do a clean build again using ant clean all and check if the code in the customAddon should move to [storefront]>web>addonsrc>customcommerceorgaddon. Once done you should check the customcommerceorgaddon project.properties [storefront].additionalWebSpringConfigs.customcommerceorgaddon =classpath\:/customcommerceorgaddon/web/spring/customcommerceorgaddon-web-spring.xml

Once everything is verified , just run the hybrisserver and your custom controller should now be picked up.

thanks,

srini_y
Explorer
0 Likes

Steps to extend the ootb addon controller:
1) Implement your own controller extending the ootb addon controller. Don't mark it with @ Controller annotation.
2) Add the bean definition for the custom controller in your custom addon web-spring.xml without any alias.
3) Make sure that your addon web-spring.xml is provided in the storefront's additionalWebSpringConfigs as himanshu.mehta1 mentioned.
4) Build & start your server. Your custom controller will be picked.

<bean name="userManagementPageController" class="***.controllers.pages.CustomUserManagementPageController" />
former_member1320010
Participant
0 Likes

Have you added the below property in your project.properties or local.properties

.additionalWebSpringConfigs.myAddOn=classpath:/myAddOn/web/spring/myAddOn-web-spring.xml

Former Member
0 Likes

Any news on how this issue can be solved?

Thanks