### WebApps Hints

Some useful hints when developing Webserver applications.
WebSocker vs WebServer Handler
• Both types of handlers can be combined in the same app.
• WebSocket handlers are useful for interaction with the user browser.
• WebSockets handlers can also be used with apps when to maintain an active connection. This is less common.
• Regular handlers are useful to implement an API. For example to allow a mobile app to interact with the server.
• Static files (html, js, css, ...) are served automatically by the server.
Define IDs in HTML in lowercase
Ensure to define the IDs in lowercase in the HTML files (located in the www folder).
The related usage of the defined IDs in the B4J code can be in any case.
Example defining a Button using jQuery Mobile
In HTML (www/index.html)
<div data-role="page" data-theme="a" id="indexpage">
<div data-role="content">
<h1>B4J Webserver Test</h1>
<hr>
<button id="btnhelloworld" data-icon="info">Hello World</button>
</div>
</div>
In B4J
' Show standard JavaScript dialog Alert for the button "btnhelloworld" defined in www/index.html
`Sub btnHelloWorld_Click(Params As Map)
Log("Clicked button Hello World...")
ws.Alert("Hello World")
End Sub`
Use the Browser Console Log for JavaScript developments
To debug and view output, recommend to make use of the Browser Log, like FireBug for FireFox.
Writing to the Console with JavaScript
<script>
//
console.log("Logentry");
var s = "My LogEntry"
console.log("Content Row:" + s );

Changed: , Category: WebApps, File: T6C277M2081.htm, ID: 2081