1. SAP UI5 Bootstraping(UI5 연동, 초기화)
SAP UI5 Bootstraping(UI5 연동)이란?
이전 단계는 UI5 서버를 이용해 단순 HTML을 호출한 것으로 UI5 Framework를 사용하지 않았다. 이번에 작성하는 Bootstraping 과정을 통해 UI5 Framework가 초기화되고 실제 연동되게 된다.
( The previous step was to call simple HTML using a UI5 Server, and the UI5 Framework was not used. Through the Bootstraping process created this time, the UI5 Framework is initialized and actually linked.)
실행 결과(Results of this step):
실행 순서(Order of execution of this step):
- 필요한UI5 라이브러리를 추가한다.
(Add the required UI5 library.) - webapp/index.html 파일에 bootstrap 관련 코딩한다.
(Coding related to bootstrap in the webapp/index.html file.) - index.html과 연동되어 실행될 webapp/index.js 신규 생성한다.
(Create a new webapp/index.js that will run in conjuction with index.html.)
1. 필요한UI5 라이브러리를 추가(Add the required UI5 library)
- Terminal 창에서 아래 명령어 실행을 통해 필요한 라이브러리를 추가한다.
(In the Terminal window, add the required libraries by running the following commands.) - ui5 add sap.ui.core
- ui5 add sap.m
- ui5 themelib_sap_horizon
- Terminal에서 명령어 실행하면, 신규 추가되는 라이브러리는 ui5.yaml 파일에 자동으로 작성된다.
(When the command is executed in Terminal, the newly added library is automatically created in the ui5.yaml file.)
2. webapp/index.html 파일에 bootstrap 관련 코딩
(Coding related to bootstrap in the webapp/index.html file.)
- webapp/index.html 파일에 아래 내용 추가한다.
(Add the following to the webapp/index.html file.)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>UI5 Tutorial</title> <script id="sap-ui-bootstrap" src="resources/sap-ui-core.js" data-sap-ui-theme="sap_horizon" data-sap-ui-libs="sap.m" data-sap-ui-compatVersion="edge" data-sap-ui-async="true" data-sap-ui-onInit="module:ui5_tutorial/index" data-sap-ui-resourceroots='{ "ui5_tutorial": "./" }'> </script> </head> <body> <div>Hello World</div> </body> </html> | cs |
- 코드 해석(Code description):
- id="sap-ui-bootstrap"
: 약속된 ID 값으로 반드시 "sap-ui-bootstrap"으로 작성한다.
(Make sure to write "sap-ui-bootstrap" with the promised ID value.) - src="resources/sap-ui-core.js"
: UI5 core 모듈인 sap-ui-core.js 파일의 경로를 표시한다.
(Displays the path of the "sap-ui-core.js" file, which is a UI5 core module.) - "resources/sap-ui-core.js"는 로컬 ui5 서버에 해당 파일이 존재해야만 하며, 개발 용도로만 사용을 권장한다.
("resources/sap-ui-core.js" must exist on the local ui5 server and is recommended for development puposes only.) - src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"로 작성하면, SAP Web Page에 있는 파일을 직접 사용하는 것으로 배포 시 사용을 권장한다.
(If you write src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js", it is recommended to use the file directly on the SAP Web Page for deployment.) - 자체 CDN(Content Delivery Network)를 구성하여 관리할 수도 있다.
(A content delivery network(CDN) may be configured and managed.) - data-sap-ui-theme="sap_horizon"
: SAP 기본 테마를 "sap_horizon"으로 설정하는 것이다. 설정 가능한 테마 종류는 SAP Site를 참조.
(Set SAP default theme to "sap_horizon". See SAP Site for configurable theme types.)
- data-sap-ui-libs="sap.m"
: UI5 동작을 제어하기 위한 가장 기본이 되는 라이브러리를 추가한다.
(Add the most basic library for controlling UI5 behavior.) - data-sap-ui-compatVersion="edge"
: UI5 모듈의 적용 버전 셋팅으로 "edge"는 최신 버전을 의미한다.
("edge" means the latest version by setting the applied version of the UI5 module.) - 특정 Version으로 고정하고 싶으면 버전 정보를 직접 입력하면 된다.
(If you want to fix it with a specific version, you can enter the version information directly.)
- data-sap-ui-async="true"
: Bootstrap 과정을 비동기 방식으로 동작하도록 셋팅한다.
(Set the Bootstrap process to operate in an asynchronous manner.) - data-sap-ui-onInit="module:ui5_tutorial/index"
: Html 에서 초기화를 위해 사용할 javascript 파일의 경로와 파일명을 setting한다.
(Set the path and filename of the javascript file to be used for initialization in HTML.)
Html 에서 직접 javascript 로직 코딩 및 실행을 회피하여 보안을 높이기 위한 방법이다.
(It is a method to increase security by avoiding javascript logic coding and execution directly from HTML.) - data-sap-ui-resourceroots='{"ui5_tutorial":"./"}'
: ui5_tutorial 이라는 이름으로 최상위 root 경로(project 폴더/webapp)를 선언하는 의미이다.
(The name ui5_tutorial means declaring the top root path(project folder/webapp).) - webapp/index.js 파일을 신규 추가 후 아래 내용으로 작성한다.
(After adding a new webapp/index.js file, write the contents below. - index.html에서 초기화 동작을 위한 index.js 파일을 호출하였고, 현재는 alert 팝업이 나타나도록 초기화한다.
(I called the index.js file for the initialization action in index.html, and now I initialize the alert pop-up to appear.)
2 3 4 5 | sap.ui.define([], () => { "use strict"; alert("UI5 is ready"); }); | cs |
댓글
댓글 쓰기