3. What is Jaxer
Jaxer Core Jaxer Framework
● ●
Server-side browser JS based
● ●
environment Marshalling
●
(Spider-Monkey)
Access to server
●
Useful Server
●
libraries.
Extensions
Don Albrecht
dalbrecht@getcollc.com
4. Why Jaxer
Improve perceived performance by migrating
●
some progressive enhancement to the server
Prevent replication of code between front end
●
and back end.
Mash ups
●
Aspects
●
Don Albrecht
dalbrecht@getcollc.com
5. Running Code
Normal Markup passes through un-executed.
●
Add the runat=”” attribute to script tags.
●
runat=”server” : server only
–
runat=”both” : code available on both client and
–
server.
Don Albrecht
dalbrecht@getcollc.com
6. Proxy
Server side functions can be proxied to the
●
client side.
Function x() {} x.proxy=true;
●
When x is called on the client, a synchronous
●
call is made to the server where x is
executed and it's response is returned as
json.
Don Albrecht
dalbrecht@getcollc.com
7. Setting Up The Database
<script runat=”server” type=”text/javascript”>
var sql = quot;CREATE TABLE IF NOT EXISTS users quot;+
quot;(user_id INTEGER NOT NULLquot; +
quot;, username VARCHAR(45)quot; +
quot;, password VARCHAR(45)quot; +
quot;); quot;;
Jaxer.DB.execute(sql);
</script>
Don Albrecht
dalbrecht@getcollc.com
8. Registering A User
<script src=quot;lib/md5.jsquot; type=quot;text/javascriptquot; runat=quot;serverquot;></script>
<script src=quot;lib/jquery/jquery-1.3.2.min.jsquot; type=quot;text/javascriptquot; runat=quot;bothquot;></script>
<script type=”text/javascript” runat=”server”>
function createLogin( username, password){
var passhash = hex_md5( password );
var userId = createId();
var resultset = Jaxer.DB.execute(quot;Insert Into users (user_id, username, password) VALUES( ?, ?, ? );quot; ,
[createId(), username, passhash]);
return userId;
}
createLogin.proxy = true;
</script>
Don Albrecht
dalbrecht@getcollc.com