DWR:
In the development process, you mainly do:
1. Develop Java classes. No new things.
2. Configure Java classes.
--At the time of configuration, the <create .../> element is used.
<create.../> element is used to build Java class into a JS object.
Where the <create.../> element creator specifies the creator to use.
3. Invoke Java methods remotely in the browser's JS code.
1. Remote, asynchronous invocation of Java methods requires an extra pass in a parameter.
A parameter is a callback function that is shaped like function (data) {}.
Where data represents the return value being invoked.
2. When Java method parameters, return values are scalar values (base type, string, Date), JS has a corresponding type.
However, the parameters of the Java method, the return value is a composite type, such as person, cat, etc. vo, or collection, etc. ...
This is related to Java type ←→js type conversion. This requires the use of a converter .
The AJAX framework can be grouped into 3 categories:
-Lightweight JS Library: Prototype, JQuery.
-Complex JS Library +ui library: Ext js, Dojo.
-Remote RPC style: DWR
2. Invoke the JQuery method to modify the jquery object.
Modify the content. HTML ()/html (content)/Val ()/val (content)
Modify Css:height () width () css ()
Modify Normal property attr ()/attr (property name, property value)
Add append ()/appendto prepend/prependto Insertbefore/before Insertafter/after
Delete
Replace
Package
------------DWR------------
Remote RPC-style AJAX framework
Install DWR
A. Copy jar packages.
B. Configure the core controller (Dwrservlet) in the Web.xml file.
C. Add dwr.xml configuration file.
In the development process, you don't even need to understand the asynchronous request, response concept, just as follows:
1. Develop Java classes.
2. Configure Java classes.
1. Creator: Responsible for creating Java classes, Java objects into a JS object that allows remote invocation.
<create creator= "NEW/SPRING/EJB" javascript= "" >
<param name= ""/> The parameters that are required for different creators are different.
</create>
2. Converter: Responsible for completing the conversion between server-side Java types and browser-side JS types.
Only the bean, object converter needs to be explicitly opened and configured.
<convert converter= "Bean/object" match= "type required for conversion" >
Blacklist
White List
</convert>
3. The method of invoking Java in an asynchronous manner.
A. Simple callback. A function that has a shape like function (data) {} is added more than once during the call.
Data is the return value of the invoked method.
B. Complex callbacks: Calls with additional multiple passes to a JS object such as {callback:, timeout:}.
The JS object allows you to specify more customization options for the DWR call.
DWR's two JS libraries
1. Engine.js: A global option that is primarily used to control dwr.
When using complex callbacks, you can set some options for asynchronous invocations through the JSON object, such as the following
Timeout
Exceptionhandler
ErrorHandler
Prehook
Posthook
...
But these options are only valid for a single call, so you can use the
DWR.ENGINE.SETXXX to set global options, which are all Ajax calls that work.
Two additional features:
A. Control the order of calls.
B. Batch call: Once the interaction with the server completes multiple calls, which improves performance.
2. Util.js: For simplifying DOM operations.
$ () can be considered an abbreviation for document.getElementById ().
When we use Dwr's util.js and jquery together, the $ () function conflicts.
Workaround: Another alias for jquery $ ().
------------------------------
Working with lists
Removealloptions () deletes all options.
AddOptions (ID, array of DOM nodes);
AddOptions (the ID of the DOM node, the array of objects, the name of the property);
AddOptions (DOM node ID, object array, property name, property name);
AddOptions (ID, object, true/false) of the DOM node;
------------------------------
Working with Tables
It is not only used to manipulate tables, it can be used to manipulate the <tbody> of a table (so you can only manipulate a part of the table)
Removeallrows (Tableid/tbodyid) deletes all rows.
Addrows (Tableid/tbodyid, array, array of functions, [option])
--------------------------------
Accessing the value of a form control
Getvalue/getvalues ()
Setvalue/setvalues ()
Util.js's tool functions:
OnReturn
Todescriptivestring ()
Selectrange (' text ', N, m)
=======================
DWR Access servlet API
For example, user login, user login success, should the user information into session.
For example, if a user wants to invoke a protected page,
Whether you should check whether the user is logged in or not with sufficient permissions.
DWR is inherently part of the front-end Web-layer framework, so it must access the servlet API.
1. With the help of <