且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SAP Hybris Commerce的JSP tag和SAP BSP tag的比较

更新时间:2022-09-14 22:36:10

SAP Hybris Commerce的JSP tag和SAP BSP tag的比较

I try the approach introduced in my blog Technical data for Hybris Commerce UI – how to find the name of JSP page for a given UI

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.


SAP Hybris Commerce的JSP tag和SAP BSP tag的比较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:


SAP Hybris Commerce的JSP tag和SAP BSP tag的比较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/"%>  
<t:template>  
  <jsp:attribute name="headerarea">  
    Jerry: This is header area!  
  </jsp:attribute>  
  <jsp:attribute name="footerarea">  
    Jerry: This is footer area!  
  </jsp:attribute>  
  <jsp:body>  
    body area: Hello world!  
  </jsp:body>  
</t:template>

SAP Hybris Commerce的JSP tag和SAP BSP tag的比较SAP Hybris Commerce的JSP tag和SAP BSP tag的比较SAP Hybris Commerce的JSP tag和SAP BSP tag的比较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.


SAP Hybris Commerce的JSP tag和SAP BSP tag的比较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.


SAP Hybris Commerce的JSP tag和SAP BSP tag的比较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:


SAP Hybris Commerce的JSP tag和SAP BSP tag的比较

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(<page>).
    WRITE: / <page>-implclass COLOR COL_GROUP, ' Last accessed on:', <page>-changedon COLOR COL_KEY,
    ' Component name: ' , <page>-applname+0(20) COLOR COL_NEGATIVE, ' view name: ', <page>-pagename+0(30) COLOR COL_POSITIVE.
  ENDLOOP.