SAP Hybris Commerce的JSP tag和SAP BSP tag的比较
发布日期:2021-06-30 14:29:16 浏览次数:2 分类:技术文章

本文共 3526 字,大约阅读时间需要 11 分钟。

Recently I am studying Hybrid Commerce and try to learn how the home page of Hybris storefront is implemented.

I try the approach introduced in my blog

and find the JSP file which implements the home page:

hybris\bin\ext-template\yacceleratorstorefront\web\webroot\WEB-INF\views\responsive\pages\layout\landingLayout2Page.jsp

When I debug this file I find there are lots of usage of tag jsp:attribute as displayed below.

Then I study this tag a little bit. In order to understand how it works, I have built a small example.

(1) Create a template.tag under folder WEB-INF/tags with the following source code:

<%@tag description="Jerry template" pageEncoding="UTF-8"%>  <%@attribute name="headerarea" fragment="true" %>  <%@attribute name="footerarea" fragment="true" %>              
Jerry: This paragraph is defined in the template!!

In this template I define two fragments with ID headerarea and footerarea, and in the middle of them I also hard coded a blue div.

(2) Create a JSP file which fills the actual content into the two fragments:

<%@page contentType="text/html" pageEncoding="UTF-8"%>  <%@ taglib prefix="t" tagdir="/WEB-INF/tags/"%>  
Jerry: This is header area!
Jerry: This is footer area!
body area: Hello world!

And this is the final page displayed in browser:

And I also find the corresponding .java and compiled .class file under the work folder of my tomcat installation.

The fragment value filled in the JSP file could also be found here.

ABAP BSP

ABAP BSP(Business Server Page) has very similar name as JSP ( Java Server Page ), which indicates that it works the similar way under the hood: once a BSP page is accessed, an ABAP class is automatically generated ( if not existed yet ) to serve the page request.

See one example below.

You can still open this generated class via SE24 as what you have done for normal class, except for the fact that it is not assigned to any package.

Based on this knowledge, I have also written a small tool to list all compiled ABAP classes and their corresponding BSP view name, which could act as a kind of BSP page browse history tool.

Just specify the user name and this report will list browse history:

REPORT ztool_display_page_name.PARAMETERS: name TYPE trdir-unam OBLIGATORY DEFAULT 'WANGJER'.DATA: lt_trdir TYPE STANDARD TABLE OF trdir,      lt_page  TYPE STANDARD TABLE OF o2pagdir.TYPES: BEGIN OF ty_impl,         name TYPE o2pagdir-implclass,       END OF ty_impl.TYPES: tt_impl TYPE STANDARD TABLE OF ty_impl.START-OF-SELECTION.  SELECT * INTO TABLE lt_trdir FROM trdir WHERE unam = name.  IF sy-subrc <> 0 .    WRITE: / 'No browse history found for current user'.    RETURN.  ENDIF.  DATA: lt_impl  TYPE tt_impl,        ls_trdir TYPE trdir,        ls_impl  TYPE ty_impl.  LOOP AT lt_trdir INTO ls_trdir.    ls_impl-name = ls_trdir-name.    APPEND ls_impl TO lt_impl.  ENDLOOP.  SELECT * INTO TABLE lt_page FROM o2pagdir FOR ALL ENTRIES IN lt_impl    WHERE changedby = name AND implclass = lt_impl-name.  SORT lt_page BY changedon DESCENDING.  LOOP AT lt_page ASSIGNING FIELD-SYMBOL(
). WRITE: /
-implclass COLOR COL_GROUP, ' Last accessed on:',
-changedon COLOR COL_KEY, ' Component name: ' ,
-applname+0(20) COLOR COL_NEGATIVE, ' view name: ',
-pagename+0(30) COLOR COL_POSITIVE. ENDLOOP.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

转载地址:https://jerry.blog.csdn.net/article/details/108293940 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:一种获取SAP HANA数据库表条目数的另类方法
下一篇:微信开发系列之七 - 使用Redis存储微信聊天记录

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月28日 11时26分22秒