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:
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 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的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2724273/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- BSP tag in CRM and JSP tag in HybrisJS
- SAP ABAP和Hybris Commerce的Sample資料
- SAP ABAP Netweaver和Hybris Commerce的部署策略
- SAP Commerce Accelerator和SAP Spartacus的技術對比
- SAP Hybris Commerce裡的資料庫表資料庫
- SAP Commerce(SAP Hybris)學習資料彙總
- SAP Commerce(原Hybris)的訂單處理框架和SAP CRM One Order框架框架
- SAP CRM WebClient UI和Hybris Commerce的懶載入機制WebclientUI
- Hybris service layer和SAP CRM WebClient UI架構的橫向比較WebclientUI架構
- SAP BSP和JSP頁面裡UI元素的ID生成邏輯JSUI
- SAP Hybris Commerce啟用customer coupon的前提條件
- SAP Hybris Commerce product讀取的除錯截圖除錯
- ABAP Netweaver, Hybris Commerce和SAP 雲平臺的登入認證
- SAP Netweaver和Hybris Commerce啟動後執行的預設操作
- 淺談SAP CRM和Hybris Commerce裡的價格架構折扣架構
- Google Tag Manager (GTM) 和 Adobe AEPL 在 SAP Spartacus 中的應用Go
- 關於 Hybris (SAP Commerce Cloud)產品的客戶群Cloud
- SAP UI5應用和Hybris Commerce的國際化(internationalization)支援UI
- SAP BSP應用有狀態和無狀態行為差異比較
- SAP Hybris的build callback和SAP ABAP的SGEN事務碼UI
- SAP Commerce(原Hybris)的一些架構圖,持續更新架構
- SAP ABAP ADBC和Java JDBC的使用比較JavaJDBC
- SAP Netweaver和Hybris的資料庫層資料庫
- SAP Hybris的Master Tenant和Netweaver的System ClientASTNaNclient
- 使用 Tag Assistant 除錯 SAP 電商雲 Spartacus UI 的 TMS 模組除錯UI
- SAP UI5 Gateway Export 和 Client Export 的比較UIGatewayExportclient
- ABAP和Java的tag(marker) interfaceJava
- SAP Hybris和ABAP Netweaver裡的DAO(Data access object)Object
- SAP UI5和React的頁面渲染效能比較UIReact
- SAP CRM,Cloud for Customer和Fiori應用的direct navigation比較CloudNavigation
- SAP Commerce Cloud SmartEdit 的安裝Cloud
- SAP Commerce Cloud 的 Security 策略概述Cloud
- Tag
- SAP Commerce Cloud 裡的 User 模型和 Restriction 的關係Cloud模型REST
- XML tag has empty body less... (Ctrl+F1) Reports empty tag body. The validation works in XML / JSPXMLJS
- SAP Commerce Cloud 裡的 jsapps 和 jsapps-ssr 容器CloudJSAPP
- SAP CRM和Cloud for Customer裡的Formatted Text控制元件的比較CloudORM控制元件
- SAP CRM WebClient UI和Hybris的controller是如何被呼叫的WebclientUIController