AppML Prototipi


Bu bölümde, bir web uygulaması için bir prototip oluşturacağız.


Bir HTML Prototipi Oluşturun

İlk olarak, en sevdiğiniz CSS'yi kullanarak düzgün bir HTML prototipi oluşturun.

Bu örnekte W3.CSS kullandık:

Örnek

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

{{ ... }} Gelecekteki veriler için yer tutuculardır.


AppML Ekle

Bir HTML prototipi oluşturduktan sonra AppML ekleyebilirsiniz:

Örnek

<!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'yi ekleyin:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js">

Yerel bir WebSQL veritabanı ekleyin:

<script src="https://www.w3schools.com/appml/2.0.3/appml_sql.js">

Bir veri kaynağı tanımlayın:

appml-data="customers.js"

Kayıtlardaki her kayıt için tekrarlanacak HTML öğesini tanımlayın:

appml_repeat="kayıtlar"

Basitleştirmek için, bir veritabanına bağlanmadan önce gibi yerel verilerle başlayın .


AppML Modeli Oluşturun

Bir veritabanını kullanabilmek için bir AppML veritabanı modeline ihtiyacınız olacak:

proto_customers.js

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

Yerel bir veritabanınız yoksa, bir Web SQL veritabanı oluşturmak için AppML modelini kullanabilirsiniz.

Tek bir kayıt içeren bir tablo oluşturmak için şuna benzer bir model kullanın: .

Yerel bir veritabanı oluşturmak, IE veya Firefox'ta çalışmaz. Chrome veya Safari kullanın.

Modeli uygulamanızda kullanın. Veri kaynağını local?model=proto_customers_single olarak değiştirin :

Örnek

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

Birden Çok Kayıtlı Yerel Veritabanı Oluşturun

Birden çok kayıt içeren bir tablo oluşturmak için şuna benzer bir model kullanın: .

Veri kaynağını local?model=proto_customers_all olarak değiştirin

Örnek

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

Gezinme Şablonu Ekle

Tüm uygulamalarınızın ortak bir gezinme araç çubuğuna sahip olmasını istediğinizi varsayalım:

Bunun için bir HTML şablonu oluşturun:

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>

Şablonu "inc_listcommands.htm" gibi uygun bir adla bir dosyaya kaydedin.

Şablonu appml-include-html özniteliğiyle prototipinize ekleyin :

Örnek

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