AppML 프로토타입


이 장에서 우리는 웹 애플리케이션을 위한 프로토타입을 만들 것입니다.


HTML 프로토타입 만들기

먼저, 좋아하는 CSS를 사용하여 괜찮은 HTML 프로토타입 을 만듭니다.

이 예에서는 W3.CSS를 사용했습니다.

예시

<!DOCTYPE html>
<html lang="en-US">

<title>Customers</title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

<body>

<div class="w3-container">
<h1>Customers</h1>
<table class="w3-table-all">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
</div>

</body>
</html>

{{ ... }} 미래 데이터의 자리 표시자입니다.


AppML 추가

HTML 프로토타입을 만든 후 AppML을 추가할 수 있습니다.

예시

<!DOCTYPE html>
<html lang="en-US">
<title>Customers</title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<script src="https://www.w3schools.com/appml/2.0.3/appml_sql.js"></script>
<body>

<div class="w3-container" appml-data="customers.js">
<h1>Customers</h1>
<table class="w3-table-all">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
</div>

</body>
</html>

AppML 추가:

<스크립트 src="https://www.w3schools.com/appml/2.0.3/appml.js">

로컬 WebSQL 데이터베이스 추가:

<스크립트 src="https://www.w3schools.com/appml/2.0.3/appml_sql.js">

데이터 소스 정의:

appml-data="customers.js"

레코드의 각 레코드에 대해 반복할 HTML 요소를 정의합니다.

appml_repeat="기록"

간단하게 하려면 데이터베이스에 연결하기 전에


AppML 모델 생성

데이터베이스를 사용하려면 AppML 데이터베이스 모델이 필요합니다.

proto_customers.js

{
"rowsperpage" : 10,
"database" : {
"connection" : "localmysql",
"sql" : "Select * from Customers",
"orderby" : "CustomerName",
}

로컬 데이터베이스가 없는 경우 AppML 모델을 사용하여 웹 SQL 데이터베이스를 생성할 수 있습니다.

단일 레코드로 테이블을 생성하려면 와 같은 모델을 사용하십시오 .

로컬 데이터베이스 생성은 IE 또는 Firefox에서 작동하지 않습니다. 크롬이나 사파리를 이용하세요.

애플리케이션에서 모델을 사용하십시오. 데이터 소스를 local?model=proto_customers_single 로 변경합니다 .

예시

<div class="w3-container" appml-data="local?model=proto_customers_single">
<h1>Customers</h1>
<table class="w3-table-all">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
</div>

여러 레코드가 있는 로컬 데이터베이스 생성

여러 레코드가 있는 테이블을 만들려면 와 같은 모델을 사용하세요 .

데이터 소스를 local?model=proto_customers_all 로 변경

예시

<div class="w3-container" appml-data="local?model=proto_customers_all">
<h1>Customers</h1>
<table class="w3-table-all">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
  <td>{{Country}}</td>
  </tr>
</table>
</div>

탐색 템플릿 추가

모든 애플리케이션에 공통 탐색 도구 모음이 있기를 원한다고 가정합니다.

이에 대한 HTML 템플릿을 만듭니다.

inc_listcommands.htm

<div class="w3-bar w3-border w3-section">
<button class="w3-button" id='appmlbtn_first'>&#10094;&#10094;</button>
<button class="w3-button" id='appmlbtn_previous'>&#10094;</button>
<button class="w3-button w3-hover-none" id='appmlbtn_text'></button>
<button class="w3-button" id='appmlbtn_next'>&#10095;</button>
<button class="w3-button" id='appmlbtn_last'>&#10095;&#10095;</button>
<button class="w3-btn ws-green" id='appmlbtn_query'>Filter</button>
</div>

<div id="appmlmessage"></div>

템플릿을 "inc_listcommands.htm"과 같은 적절한 이름으로 파일에 저장합니다.

appml-include-html 속성을 사용하여 프로토타입에 템플릿을 포함합니다 .

예시

<div class="w3-container" appml-data="local?model=proto_customers_all">
<h1>Customers</h1>
<div appml-include-html="inc_listcommands.htm"></div>

<table class="w3-table-all">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
</div>