Skip to content

pyhoon/pakai-server-b4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

394 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pakai Server - Web Application framework

Version: 6.33

Create Web Application using B4J project template

Preview

Index


Templates

  • Pakai Server (6.33) min.b4xtemplate (assets excluded)
  • Pakai Server (6.33) starter.b4xtemplate recommended
  • Pakai Server (6.33) bundle.b4xtemplate (local css/js)

Depends on

Features

  • Frontend using HTMX v2.0.8, Bootstrap v5.3.8, Bootstrap Icons v1.13.1
  • Responsive design with modal dialog and toast
  • SQLite and MySQL/MariaDB backend
  • Built-in CRUD/REST examples

Improvement

  • Better UI/UX/DX compared to version 5.x
  • More flexible to generate new models
  • HTML generated using B4X
  • No JavaScript module
  • No jQuery AJAX parsing
  • JSON/XML API is optional
  • WebApiUtils is optional

Code Example

Private Sub CreateProductsTable As MiniHtml
	If App.ctx.ContainsKey("/products/table") = False Then
		Dim table1 As MiniHtml = Table.cls("table table-bordered table-hover rounded small")
		Dim thead1 As MiniHtml = Thead.cls("table-light").up(table1)
		Th.up(thead1).sty("text-align: right; width: 50px").text("#")
		Th.up(thead1).text("Code")
		Th.up(thead1).text("Name")
		Th.up(thead1).text("Category")
		Th.up(thead1).sty("text-align: right").text("Price")
		Th.up(thead1).sty("text-align: center; width: 120px").text("Actions")
		Tbody.up(table1)
		App.ctx.Put("/products/table", table1)
	End If

	DB.SQL = DB.Open
	DB.Table = "tbl_products p"
	DB.Columns = Array("p.id id", "p.category_id catid", "c.category_name category", "p.product_code code", "p.product_name name", "p.product_price price")
	DB.Join = DB.CreateJoin("tbl_categories c", "p.category_id = c.id", "")
	DB.OrderBy = CreateMap("p.id": "")
	DB.Query
	
	Dim table1 As MiniHtml = App.ctx.Get("/products/table")
	Dim tbody1 As MiniHtml = table1.Child(1)
	tbody1.Children.Clear ' remove all children
	For Each row As Map In DB.Results
		row.Put("price", NumberFormat2(row.Get("price"), 1, 2, 2, True))
		Dim tr1 As MiniHtml = CreateProductsRow
		tr1.Child(0).text2(row.Get("id"))
		tr1.Child(1).text2(row.Get("code"))
		tr1.Child(2).text2(row.Get("name"))
		tr1.Child(3).text2(row.Get("category"))
		tr1.Child(4).text2(row.Get("price"))
		tr1.Child(5).Child(0).attr("hx-get", "/hx/products/edit/" & row.Get("id"))
		tr1.Child(5).Child(1).attr("hx-get", "/hx/products/delete/" & row.Get("id"))
		tr1.up(tbody1)
	Next
	DB.Close
	Return table1
End Sub

Support this project