cancel
Showing results for 
Search instead for 
Did you mean: 

How to add componenet to the storefront by usig addon extension

Former Member
0 Kudos

Hi experts, I have a requirement that I want to add wishlist link at homepage by using addon extension .When ever click on wishlist link it returns jsp page.Through addon it does not renders the storefront.Means it renders only when you changes directly at storefront,but I want to do this by Addon . How to achieve this?Please share if you have any idea.

Thank you..

Former Member
0 Kudos

If you agree , please up vote and accept answer. :)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sindhu, I can give you idea about render a component in add on. So you can refer this and you can use component wherever you want.

youraddon-items.xml:

 <itemtype code="YourComponent" autocreate="true"
             generate="true" extends="SimpleCMSComponent" >
             <description>Represents component.</description>
 </itemtype>

Make new page template using following impex:

 INSERT_UPDATE PageTemplate;$contentCV[unique=true];uid[unique=true];name;frontendTemplateName;
 ;;yourPageTemplate;Your page;layout/yourResultPage;
 
 
 # Add Velocity templates that are in the CMS Cockpit. These give a better layout for editing pages
 # The FileLoaderValueTranslator loads a File into a String property. The templates could also be inserted in-line in this file.
 INSERT_UPDATE PageTemplate;$contentCV[unique=true];uid[unique=true];velocityTemplate[translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator]
 ;;yourPageTemplate ;$siteResource/structure-view/structure_yourPageTemplate.vm
 
 
 # Search Results Grid Page Template
 INSERT_UPDATE ContentSlotName;name[unique=true];template(uid,$contentCV)[unique=true][default='YourPageTemplate'];validComponentTypes(code);compTypeGroup(code)
 ;yourComponentSlot;;;wide
 
 INSERT_UPDATE ContentSlotForTemplate;$contentCV[unique=true];uid[unique=true];position[unique=true];pageTemplate(uid,$contentCV)[unique=true][default='YourPageTemplate'];contentSlot(uid,$contentCV)[unique=true];allowOverwrite
 ;;YourComponentSlot-yourpage;yourComponentSlot;;yourComponentSlot;true
 
 
 INSERT_UPDATE YourComponent;$contentCV[unique=true];uid[unique=true];name;actions(uid,$contentCV);&componentRef
 ;;yourComponent; Component;;yourComponent
 
 INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active;cmsComponents(&componentRef);;;
 ;;yourComponentSlot;Slot for component;true;yourComponent;;;


Make controller for clicking your link and it will return a jsp containing your component: So for add on you have to make entry in

youradd-web-spring.xml:

 <bean name="yourPageController" class="web.src.com.YourPageController"/>
  
     <!-- 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="/yourmapping/**">yourPageController</prop>
                 </props>
             </property>
     </bean>


And your controller will have that request mapping and accept that mapping and return the jsp:

 @Controller
 @RequestMapping(value = "yourmapping")
 public class YourPageController extends AbstractPageController
 {
 
 
     @RequestMapping(method = RequestMethod.GET)
     public String yourFunction( final HttpServletRequest request,
             final Model model) throws CMSItemNotFoundException
     {
 
 
         return "addon:/youraddon/pages/layout/yourResultPage";
     }
 }


If you want to know more please see this link: link text

and another link text

Hope this will help you, if yes please accept answer.

Answers (4)

Answers (4)

former_member483526
Participant
0 Kudos

Have you added your jsp page at correct location: "youraddon\acceleratoraddon\web\webroot\WEB-INF\views"?

Former Member
0 Kudos

Jsp page not rendering it gives 404 exception

Former Member
0 Kudos

After add on installation your add on JSP should be copied to storefront/WEB-INF/addons/youraddonname/views/desktop/cms/youraddonjsp.jsp . If it is copied correctly again if you see that error will clearly say that JSP file which you are returning from your addon controller is pointing to wrong path.

Former Member
0 Kudos

Yes agree with Saiprasad. Seems like your Jsp is not copied or not created at right place. Path should be like this:

youraddon\acceleratoraddon\web\webroot\WEB-INF\views\desktop\cms\yourcomponent.jsp

Former Member
0 Kudos

But jsp page rendering is not happening at storefront.

Former Member
0 Kudos

Can you tell us what is the error ... ??? Did you installed that add on correctly check it once... ?? After installation of add on your add on related controller class should be called after that add on JSP will be rendered,Check whether that controller is getting called or not... ???

Former Member
0 Kudos

Thank you so much

Former Member
0 Kudos

So please accept as answer :)