zoukankan      html  css  js  c++  java
  • SAP Hybris Commerce的JSP tag和SAP BSP tag的比较

    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 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:

    hybrisinext-templateyacceleratorstorefrontwebwebrootWEB-INFviews esponsivepageslayoutlandingLayout2Page.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" %>  
    <!DOCTYPE html>  
    <html>  
      <head>  
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
      </head>  
      
      <body>  
        <jsp:invoke fragment="headerarea"/>  
        <br></br>
        <div style="color:blue;margin-left:30px;">Jerry: This paragraph is defined in the template!!</div>
        <jsp:doBody/>  
        <br></br>
        <jsp:invoke fragment="footerarea"/>  
      </body>  
    </html> 
    

    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>
    

    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(<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.
    

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

  • 相关阅读:
    阻止a链接跳转的点击事件
    appium python版api
    Appium—python_ 安卓手机划屏幕操作
    appium-unittest框架中的断言
    Appium 服务关键字
    python mysql入库的时候字符转义
    python实现两个字典合并
    解决linux登录后总是时间过会就断开(解决ssh登录后闲置时间过长而断开连接)
    linux安装好redis,如何在window端访问?
    linux上安装redis
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13599269.html
Copyright © 2011-2022 走看看