I created addon and jsp tag, which is located at : bin\\custom\\Myaddon\\acceleratoraddon\\web\\webroot\\WEB-INF\\tags\\desctop\\product\\productList.tag
Here is code of productList.tag:
<%@ tag body-content="empty" trimDirectiveWhitespaces="true" %>
<%@ attribute name="product" required="true" type="de.hybris.platform.commercefacades.product.data.ProductData" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="ycommerce" uri="http://hybris.com/tld/ycommercetags" %>
<div class="addmybutton">
<form id="add_to_list_form" action="${addToListUrl}" method="post">
<input name="code" type="hidden" value="${product.code}"/>
<input name="isPostponed" type="hidden" value="false"/>
<input type="hidden" name="CSRFToken" value="${CSRFToken.token}">
<button id="add_to_list_submit_button" type="submit" class="b-btn b-btn--red i-fs14"><spring:theme
code="text.addToMyList"/></button>
</form>
</div>
How i can make this jsp tag appear inside the jsp page (or any jsp tag) which locates in storefront?
For instance, if I want to add my jsp tag to productLayout1Page.jsp (which automatically created when we create storefront extention).
Location of productLayout1Page.jsp: bin\\custom\\myModule\\myModulestorefront\\web\\webroot\\WEB-INF\\views\\responsive\\pages\\product\\productLayout1Page.jsp
Here is a code of productLayout1Page.jsp:
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="template" tagdir="/WEB-INF/tags/responsive/template"%>
<%@ taglib prefix="cms" uri="http://hybris.com/tld/cmstags"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/responsive/product"%>
</cms:pageSlot>
<product:productDetailsPanel />
<cms:pageSlot position="CrossSelling" var="comp" element="div" class="productDetailsPageSectionCrossSelling">
<cms:component component="${comp}" element="div" class="productDetailsPageSectionCrossSelling-component"/>
</cms:pageSlot>
<cms:pageSlot position="Section2" var="comp" element="div" class="productDetailsPageSection2">
<cms:component component="${comp}" element="div" class="productDetailsPageSection2-component"/>
</cms:pageSlot>
<cms:pageSlot position="Section3" var="comp" element="div" class="productDetailsPageSection3">
<cms:component component="${comp}" element="div" class="productDetailsPageSection3-component"/>
</cms:pageSlot>
<cms:pageSlot position="UpSelling" var="comp" element="div" class="productDetailsPageSectionUpSelling">
<cms:component component="${comp}" element="div" class="productDetailsPageSectionUpSelling-component"/>
</cms:pageSlot>
<product:productPageTabs />
<cms:pageSlot position="Section4" var="comp" element="div" class="productDetailsPageSection4">
<cms:component component="${comp}" element="div" class="productDetailsPageSection4-component"/>
</cms:pageSlot>
I should add code only to my addon. All changes should appear on storefront only after ant all
.
Elena
First you need to place your tags under any sub folder in WEB-INF\\tags. I see you already place there.
Second you need to import your tags in any other jsp or tags like below.
<%@ taglib prefix="myOwnTag" tagdir="/WEB-INF/tags/custom/folder/" %>
In the tagdir, Do not mention the tag name, just leave until the directory it is in. So in your case this will be <%@ taglib prefix="myOwnTag" tagdir="WEB-INF\\tags\\desctop\\product" %>
use the tag like below whether in jsp or another tag
<prefix-mentioned-above:name-of-the-tag/>
In your case this will be
<myOwnTag:productList/>
Check my code in the image. I created an year.tag
which i used in an other.tag
which i used in index.jsp
page.
Hope this helps you how to use tags in jsp's and another tag's.
If you want to edit html content of a page without making changes to the storefronts files, you have 2 options:
In a lot of cases it is almost inevitable to change the content of the jsp files in the storefront.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.