1. About Org.w3c.dom. * JSVM DOM2 is a characteristic of JavaScirpt itself according to W3C DOM Level 2, and a JavaScirpt's document object model is designed, which can be applied to the field of JS component development.
Org.w3c.dom. * The class in * is not only the interface in the model and the default implementation is given.
Take the event model org.w3c.dom.events. * As an example:
3 core members:
Org.w3c.dom.events.event; org.w3c.dom.events.EventTarget; Org.w3c.dom.events.EventListener;
For example, we have to realize the listening, dispatch, processing of an event, just simply press below:
Import org.w3c.dom.events.eventtarget; import org.w3c.dom.events.event;
Class Window (Name) {EventTarget.call (this);
// Todo this.name = name; // ...}
Window.Prototype.Open = function () {WINDOW.OPEN ("about: blank"); // Assign a "Open event" Var Event = New Event ("open"); Event.Name = "Window Open"; this .dispatchevent (evenet);
Customer listening code:
Var win = new window; "Test Window";
// Create an event listener object var listener1 = new EventListener (Function (EVT) {
Alert ("this name is:" this.name); Alert ("Event's name is:" evt.name); Alert ("Event target's name is: es: evt.target.name);
}, {Name: 'listener1'};
// Register the listener, listen "Open event" Win.AddeventListener ("open", listener1, false);
/ / Register a listener (registered multiple listeners) var listener2 = new EventListener (Function (EVT) {
Alert ("this name is:" this.name); Alert ("Event's name is:" evt.name); Alert ("Event target's name is: es: evt.target.name);
}, {Name: 'listener2'}; win.addeventListener ("open", listener2, false; win.open ();
It can be found that when Win.Open is executed, the assigned OPEN event is listened by Listener1, Listener2, and performs the corresponding processing.
If you develop JS components based on DOM2, things will become simpler.
2. How to define class JSVM2 that meets JSVM provides support for additional grammar, but this is not necessary, you can do not need to see the syntax of JSVM2. Design JS Class in the way in JavaScript itself, but you must follow these specifications (1). Save mode use package name class name .jsc
For example: the sable path for com.test.helloWorld is com / test / helloworld.jsc
(2). "Class" must be defined as a function type
For example: HelloWorld must be a type of FUNTION
WINDOW.COM.TEST.HELLOWORLD = Function () {}
3. About JSVM specification JSVM specification is actually very simple: (1). Each public class is stored with separate JSC files, the storage path is similar to Java:
4. The loading timing of the core components generally:
Standlone mode, timing is like this: kernel,
5.Application Module mode Application Module mode itself is simple, they are designed for the following considerations.
SOA and server linear extension requirements such that the server is gradually designed as a stateless or weak state. The work that is previously used to save the session state will be completed by the client. So a RIA application will need to be designed to be a stateful client.
The previous web applications are designed with relatively independent pages, and the switching of the page causes the client unable to save a lot of status information.
The Application of JSVM2 is a frame page that is independent of the UI and has the same lifecycle with the same lifecycle. Those who are related to specific UIs, the page that is responsible for the logic of people will run under this frame page (Application) in Module. Application is a unified portal and exit of the entire web application, and all Module pages are loaded and unified by Application and unify caches or data.
As a result, the designer can save sessions, shared data, etc. in the client through Application ...
Examples include Application Module, Application's page is relatively simple, just load the JSVM environment and set it to the Application mode, such as: