我已经开始学习Hybris,并且我想了解如何将类作为参数传递给自定义CMS组件(用于组件的根元素)。
假设在名为customNavigationComponent.jsp
的jsp文件中,我有这段代码:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="cms" uri="http://hybris.com/tld/cmstags"%>
<c:forEach items="${navigation.entries}" var="navigationLink">
<div class="custom-component-wrapper">
<cms:component component="${navigationLink.item}"/>
</div>
</c:forEach>
定制组件看起来像这样:
<a href="${component.url}">
<div>${component.linkText}</div>
</a>
我想了解将类navigation-link
作为参数传递所需要做的事情,像这样:
<cms:component component="${navigationLink.item}" class="navigation-link"/>
这样渲染的结果将类似于:
<a href="stackoverflow.com" class="navigation-link">
<div>Lorem Ipsum</div>
</a>
<cms:component component="${navigationLink.item}" class="navigation-link"/>
请检查https://help.sap.com/doc/a4265d5ea8314eb2929e6cf6fb8e35a5/1811/en-US/index.html
为了更好地理解它,您可以将其与c:forEach
进行比较。在https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/c/forEach.html,您将找到c:forEach
可用的属性列表,如果您想更深入地研究,可以进一步检查https://tomcat.apache.org/taglibs/standard/apidocs/javax/servlet/jsp/jstl/core/LoopTagSupport.html如果要使用语句,则需要创建一个自定义标签。