State and EventsContents
API Links
Jaxer provides four state contexts, with each state having its own container to persist values. To illustrate session state: when a user closes and then reopens a browser window of a web application yet remains logged in, the state of that user's session remains in effect. ContextsThe four states, from the narrowest scope to the broadest, are:
Using the State ContainersEven though each state is stored internally as a Jaxer.Container object, you don't interact though the Container API; instead, your code treats each state as if it were a normal JavaScript associative array:
Jaxer.session["username"] = "Bullwinkle";
var username = Jaxer.session["username"];
var exists = ("username" in Jaxer.session);
delete Jaxer.session["username"];
Jaxer.session = {};
Jaxer.application["app_key"] = "s0m3h4sh";
var app_key = Jaxer.application["app_key"];
var akExists = ("app_key" in Jaxer.application);
Passing Data to the ClientThe Jaxer.clientData container is used to send data from the server to the client at the end of server-side page processing. Using When Jaxer begins to process a page at the server, Session State and ScalingJaxer stores session state in the database it's configured to use. If scalability is required, it's best to configure Jaxer to use an external database instead of the internal SQLite database. Multiple Jaxer servers will then be able to share session data upon requests. Jaxer and Event HandlersTypically the interesting events in a web application occur on the client: a document finishes loading, the user clicks a link or submits a form, or hovers her mouse over an image. Because the events happen after the server completes its processing by default the events aren't available to handle with Jaxer.
Your code can, though, in unobtrusive fashion, assign
handlers for events dynamically in processing the DOM before it gets streamed to the user's browser. Since one powerful
use case for Jaxer is to build pages dynamically on the server function clickMe() {
// do something interesting here
}
var inp = Document.getElementById('someElement');
// your first instinct is the following line but it doesn't work:
// inp.onclick = clickMe;
// instead, use setEvent:
Jaxer.setEvent("onclick", input, clickMe);
// the generated client side code you'll see using View Source
// should be similar to:
Event Listeners
Your Jaxer apps can leverage
Note that the The behavior of events listeners assigned to the |
