When building Web and Mobile Apps in Lianja, WebViews can be dynamically generated using dynamic server pages.
Dynamic server pages contain HTML5 and directives that tell the Cloud Server how to process the contents of the page.
Code:
<%@ Language=VFP %>
or
Code:
<%@ Language=JavaScript %>
When a Lianja/VFP Server Page is executed the following are available to the script in addition to the complete VFP compatible cross-platform scripting language implemented in Lianja.
Global associative arrays:_REQUEST[]
_SERVER[]
_ARGS[]
_GET[]
_POST[]
_FILES[]
_COOKIE[]
_SESSION[]
Global objects:Response
write( text )
writeFile( filename )
addCookie(name, value)
addHeader(name, value)
clear()
flush()
redirect( url )
authenticate( [message] )
appendToLog( message )
include( filename )
Built-in commands/functions:
? cExpression
echo cExpression
move_uploaded_file(tofilename, fromfilename)
die(message)
include( cExpression )
object = require( cExpression )
odata_Create( url, jsondatastring )
odata_Read( url [, filename] )
odata_Update( url, jsondatastring )
odata_Delete( url, jsondatastring )
JavaScript Server Pages are modelled on PHP Server Pages. When a JavaScript Server Page is executed the following are available to the script in addition to the built-in JavaScript functions.
These will be familiar to PHP Web developers.
Global associative arrays(objects):$_REQUEST[]
$_SERVER[]
$_ARGS[]
$_GET[]
$_POST[]
$_FILES[]
$_COOKIE[]
$_SESSION[]
Global objects:Lianja.
execute( vfp_command )
evaluate( vfp_expression )
openDatabase( databasename )
openRecordSet( table_or_sqlselect )
moveFirst()
moveNext()
movePrevious()
moveLast()
move()
moveRelative()
moveBookmark()
findFirst( condition )
findNext( condition )
findPrevious( condition )
findLast( condition )
edit()
update()
delete()
requery()
field( name_or_number )
.name
.type
.width
.decimals
.value
close()
bof
eof
found
nomatch
recno
reccount
fieldcount
index
filter
close()
Responsewrite( text )
writeFile( filename )
addCookie(name, value)
addHeader(name, value)
clear()
flush()
redirect( url )
authenticate( [message] )
appendToLog( message )
include( filename )
Built-in functions:print( cExpression );
echo( cExpression );
move_uploaded_file(tofilename, fromfilename);
die(message);
debugout(message);
include( cExpression );
object = require( cExpression );
odata_Create( url, jsondatastring );
odata_Read( url [, filename] );
odata_Update( url, jsondatastring );
odata_Delete( url, jsondatastring );
tmpnam()
objectType( object_fieldname )
objectRead( from_filename, object_fieldname )
objectWrite( to_filename, object_fieldname )
base64_encode_object( object_fieldname, width, height)
unlink( filename )
The following is an example Lianja JavaScript Server Page.
Code:
<html>
<body>
<%
// Note that just as in PHP, JavaScript Server Pages can use include_once( filename) and include(filename)
// The path of the filename is relative to the directory containing this script.
include_once("library_example.jssp");
// The Lianja global object provides embedded database access
db = Lianja.openDatabase("southwind");
print("db=" + typeof db);
print("<br>");
// Lianja.openDatabase() returns a Database object so now we can open a RecordSet
rs = db.openRecordSet("select * from customers");
print("rs=" + typeof rs);
print("<br>");
print("Fieldcount="+rs.fieldcount);
print("<br>");
%>
<table>
<%
print("<tr>");
for (i=0; i<rs.fieldcount; ++i)
{
print("<td>"+rs.field(i).name+"</td>");
}
print("</tr>");
rs.moveFirst();
for (j=0; j<rs.reccount; ++j)
{
print("<tr valign='top'>");
for (i=0; i<rs.fieldcount; ++i)
{
print("<td>"+rs.field(i).value+"</td>");
}
print("</tr>");
rs.moveNext();
}
rs.close();
db.close();
%>
</table>
</body>
</html>
Q:
Do you need to write code like this to run Lianja Web and Mobile Apps.
A:
If you follow best practices no you don't but if you want to format a custom WebView section or use a third party JavaScript framework this is when you would use dynamic server pages.
And by the way, they are *very* fast. HTTP web connections and ODBC connections to MSSQL / MySQL / PostgreSQL etc are pooled internally.
the use of .rsp pages in WebView sections together with the fact that the Lianja system object reference is injected into them means that any custom WebView code can interact with the other parts of the Lianja Web Framework using Lianja.showDocument(), Lianja.evaluate(), Lianja.getElementByiD() etc.
These custom webviews can be dynamically generated by ,rsp pages and are inner framework agnostic. This provides you with the ability to create some quite compelling Apps.
Remember also that you can generate dynamic content in JavaScript too using .jssp files in the same way as you would use .rsp files.
For anyone who is not yet familiar with .rsp files, they contain html5 with code blocks in them that generate dynamic content. They are very similar to .php files but you write in Lianja/VFP instead of PHP.
Its worth pointing out that the LianjaWebFramework is a meta framework that includes a lot of pre-built data-bound sections as well as full client / server CRUD integration, App center and dynamic app loading, page navigation for SPA (Single Page Applications), etc. It integrates the front end UI view with the Lianja Cloud Server that handles business logic and database independent data access.
This is what constitutes the whole Lianja Platform (The Lianja APaaS) together with the Lianja App Builder for visually designing and building the Apps whether they be desktop, web or mobile.
What some developers do not yet realize is that the Lianja platform itself has been designed to provide a means of developing Apps using Agile Development techniques with continuous delivery. As we release the Mobile App building functionality in v2.0 this will become more obvious and we will be providing some tutorials on the blogs that explain Agile Development and Continous Delivery and how these relate to Lianja.
All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
Bookmarks