I dwr Chinese document on a collation do dwr.xml purely jobs they take, there are useful do not forget to top friend you, leave a contact with the exchange of learning! Welcome to my site to exchange technical www.ithuzhu.com
dwr.xml is the DWR configuration file. By default, it should be on the WEB-INF directory (web.xml directory) under the
Create a document dwr.xml
dwr.xml paper is structured as follows:
<! DOCTYPE dwr PUBLIC
"- / / GetAhead Limited / / DTD Direct Web Remoting 1.0 / / EN"
<! - Init is only needed if you are extending DWR ->
<! - Without allow, DWR isn't allowed to do anything ->
<convert converter="..." match="..."/>
<! - You may need to tell DWR about method signatures ->
</ dwr> Here are some terms must be understood that the terminology - the parameters will be converted, remote Bean will be created. So if you have a name A, bean, it has a method called A.blah (B) then you need an A and a B of the creator of the converter.
allow the definition of paragraphs inside the DWR can create and test the type of conversion.
dwr.xml elements create document is structured as follows:
<param name="..." value="..."/>
<auth method="..." role="..."/>
creator attribute is necessary - it is used to specify the use of that device to create.
By default there are eight kinds of creation DWR1.1 browser. They are:
new: with the new keyword to create Java objects.
none: it does not create objects, see the following reasons. (v1.1 +)
scripted: through the use of BSF scripting language to create objects, such as BeanShell or Groovy.
spring: visit through the Spring framework Bean.
jsf: using JSF's Bean. (v1.1 +)
struts: the use of Struts-FormBean. (v1.1 +)
pageflow: visit the Beehive or Weblogic's PageFlow. (v1.1 +)
If you need to write to create its own browser, you must register it in the init part.
scope attribute servlet specification is very similar to the scope. It allows you to specify the bean in the scope of what the life. Options are "application", "session", "request" and "page". These values for the Servlet and JSP developers should be very familiar with.
scope attribute is optional. The default is "page". If you want to use "session" the need for cookies. DWR does not support current ULR rewriting.
param element is used to specify other parameters to create devices, each different constructor. For example, "new" need to know to create a device to create the object type is. Each parameter to create the document in their find. Please check the link above.
include and exclude element allows the creation of devices to limit access to class methods. Create a list must include or exclude the specified list of one. If it is implying that include a list of the default access policy is "refused"; exclude list if it is implying that the default access policy is "allowed."
For example, in addition to refusing to prevent setWibble () outside of all methods, you should add the following in dwr.xml.
<param name="class" value="com.example.Fred"/>
</ create> for adding elements to create the type of all methods are visible by default.
auth element allows you to specify a J2EE role as the future of access control checks:
<param name="class" value="com.example.Fred"/>
<auth method="setWibble" role="admin"/>
new creation DWR has been in default of the statement: <creator/>. You do not need to add this dwr.xml documents, it is already in the DWR's internal documents of the dwr.xml.
The creation of the default browser through the categories early enough function to create object instance. To create new devices with a number of advantages:
Safety: DWR created event object, the shorter the survival of many inconsistencies in the value of call center with fewer opportunities for error.
Low memory consumption: if your site is very large users, this could reduce the creation of VM memory overflow.
You can use the following to create new devices to create a remote call Bean:
<param name="class" value="java.util.Date"/>
none 'to create the object does not create any - it will assume that you do not need to create the object. This may be correct, for two reasons.
You may not scope in the use of the "page" (see above), and in front of this object has been created in this scope, and then you do not need to re-create the object.
There is also a situation is to call the method is static, then do not need to create the object. DWR will be called before the creation of devices to check this method is not static.
Both cases for appeal, you still need to class parameters, used to tell DWR which is the object of the type of operation is.
DWR to create scripted already in default a statement: <creator/>
Used this to create scripts to implement the BSF has been Bean, for example:
<param name="language" value="beanshell"/>
return EmailValidator.getInstance ();
</ allow> script to create device has the following parameters:
Parameters described in DWR version
language 1.0 scripting language, string, such as' beanshell '. (required)
script 1.0 to perform the script. (Required, unless there scriptPath parameters)
scriptPath 1.1 script file path. (Required, unless the script parameters)
reloadable 1.1 whether the detection of changes script file to re-load (optional, default true)
class 1.0 to create the type of object (optional). If you do not get DWR to create the type of browser.
Need to know to use this to create themes, you need to put some auxiliary library under WEB-INF/lib folder: BSF the jar package, the scripting language you use the jar package.
When a category is created by script, and scope is a session or application, if you change the script, session of the class and type of script on the inconsistent. This error will appear. Although the web containers do not have to restart, but users need to log off (or in some way to empty the session), and then log on.
When the clazz parameter is empty, and used to create new instances, DWR simple call class.newInstance () method. This method is no problem, unless the script is using a parameter to create a category, or a function call to configure this type. Unfortunately, each request must be re-run the above script and cause problems.
Allows the creation of DWR and Spring to work with you the steps to confirm the latest version of the DWR. Spring has changed the creation of browser, so you'd better check the latest version of the DWR.
Sure you check the contents of the beginning of the guide.
Confirm you in the Spring of Bean outside DWR to work well.
Configured to work with DWR and Spring. (See below)
View a demo page: http://localhost:8080/ [YOUR-WEBAPP] / dwr, check whether there is a spring of the Bean.
DWR is not running for the Spring period of dependence, so if you do not use Spring then the support of Spring will not have any affect.
Find this spring will create a device configured in the Bean, using Spring to create them. If you're already using Spring, then this will create a very useful device.
You can through the following methods to create a long-distance calls Bean:
<param name="beanName" value="Shiela"/>
</ allow> Find your Spring configuration There are three ways to find configuration file:
The easiest way is to use org.springframework.web.context.ContextLoaderListener. You do not have to use all features of Spring-MVC, only enough of the Listener, so this is a good program. You need to do in WEB-INF/web.xml in the following configurations:
<param-name> contextConfigLocation </ param-name>
<param-value> / WEB-INF/classes/beans.xml </ param-value>
</ listener> I can find the best ContextLoaderListener document is javadoc. If you know a better document, please tell me.
Rob Sanheim also pointed out that a deeper understanding of the document ContextLoaderListener.
Parameters of the use of location * If you want to use in which dwr.xml specified bean, you can use the location * parameter. You can specify any number of documents, as long as the parameters to the start location and can only. For example: location-1, location-2. These location was used as the Spring of ClassPathXmlApplicationContext parameters:
<param name="beanName" value="Shiela"/>
<param name="location" value="beans.xml"/>
</ allow> direct set BeanFactory
SpringCreator there is a static method setOverrideBeanFactory (BeanFactory) a way to programmatically set directly BeanFactory.
DWR and Spring configuration
Bram Smeets has written an interesting blog, teach you to configure DWR to use beans.xml instead of WEB-INF/web.xml.
I have to specify how beans.xml are very interested in dwr.xml, although it seems some of the feeling of Spring infectious diseases. Some people know how to achieve it? Please join the mailing list and to tell you.
DWR consists of two JSF extension points, a creation and a ServletFilter.
'jsf' to create device
DWR1.1 experience, there is a version of JsfCreator. Weizai dwr.xml you can use in this way:
<param name="managedBeanName" value="beanName"/>
<param name="class" value="your.class"/>
</ allow> This will allow you through the DWR call ManagedBean.
The Servlet Filter
DWR / Faces filter allows you to JSF life cycle is not in the FacesContext call Bean.
To use the JsfCreator, you've got to DWR / Faces in the web.xml filter added.
<filter-name> DwrFacesFilter </ filter-name>
<filter-class> uk.ltd.getahead.dwr.servlet.FacesExtensionFilter </ filter-class>
<filter-name> DwrFacesFilter </ filter-name>
<url-pattern> / dwr / * </ url-pattern>
</ filter-mapping> The two need to put in web.xml the filter and other filter-mapping together.
Almost DWR to work with any Framework. This site (DWR's official website) is proof of this, because it is in Drupal (PHP) to use DWR.
DWR and Struts has two levels of integration. The most basic level is the simultaneous use of two Framework, this is a very easy, but it does not allow sharing between DWR and Struts the Action.
DWR can call any method, there is no reason to prevent you from Struts in DWR call Action, unless you do not want to use. What is ActionForm content, when the return ActionForward how to do at DWR?
A better way is to remodeling you want to call the Action, to extract the logic of Action. DWR and the Action you can also call the same way.
The 'struts' to create device
DWR1.1 added a StrutsCreator. Weizai dwr.xml you can use in this way:
<param name="formBean" value="formBeanName"/>
</ allow> This allows you to call in FormBean the DWR.
The beginning of the order of use if you want to assure you StrutsCreator then Struts in DWR initialized before. You can put Struts in the web.xml settings <load-on-startup> lower than DWR.
create a pageflow browser
A DWR can create and Weblogic or the Beehive to work with PageFlow.
The 'pageflow' Creator
DWR1.1 add a PageFlowCreator. You can use:
</ allow >---------------------------------------------- use the static method ----------------------------------
DWR will be called before the creation of devices to check this method is not static, and if so will not be called to create. It is clear that the creation of logic applies to all devices, in spite of this "null" is most likely to create a configuration. The application of single-case type category for the creation of a single case, it is best to apply BeanShell and BSF instantiated object. For more information see 'Scripted' of other devices to create devices to create what I need to occasionally create some new devices, the most common is a EjbCreator. To discuss the creation of the new browser is a good place in the mailing list. DWR and HttpSessionBindingListeners
DWR1.x of the Bean store has created the need to pay attention to the method, it will be called each time the same request of the setAttribute ()
Method. In other words, if a Bean in the statement cycle dwr.xml set to session, then each call in the bean method, DWR will be the implementation of a
. It seems there is no harm, but if you want to use the event mechanism servlet, that is used HttpSessionBindingListener interface, you will find valueUnbound events valueBound and when each call are bound to happen, rather than you imagined to be created in the bean as well as the time when the session expired. DWR2 only the first call to create objects setAttribute (). C: Converters
We must ensure that all the parameters can be converted. JDK most types of converters have been, but you need to convert your code DWR rights. JavaBean parameters generally need a <convert
...> Definition. By default, the definition of the following types do not need to be able to convert: All types of native boolean, int, double, and so the original type of object type Boolean, Integer, etc.
java.util.Date and Date in SQL
Composed of more than an array type for more than a collection of type type (Lists, Sets, Maps, Iterators, etc.)
From the DOM, XOM, JDOM and DOM in DOM4J object (similar to Element and Document)
The following converters have a separate chapter on
Bean and Object Converters
Servlet Objects (HttpServletRequest, HttpSession, etc)
Converter based on the type of original, String, such as Simple Object BigDecimal converter has. You do not need <allow> in part in dwr.xml defined <convert>. Support their default.
By default the type of support include: boolean, byte, short, int, long, float, double, char, java.lang.Boolean, java.lang.Byte, java.lang.Short, java.lang.Integer, java.lang. Long, java.lang.Float, java.lang.Double, java.lang.Character, java.math.BigInteger, java.math.BigDecimal and java.lang.String
Web Developers Notes on Date formatting
In fact, other objects to create your own converter is simple. Converter interface that contains information Javadoc. In fact, very few cases of this need. Write in your own Converter to see before BeanConverter, it has the potential to what you want.
Part of the optional init statement is used to create the type of bean and bean-like conversion. In most cases you do not need to use them. If you need a new definition of the Creator [JavaDoc] and Converter [JavaDoc], then you need to define them here. But suggest that you check the DWR is not already supported.
In the init section just tells DWR has defined categories of the existence of these extensions are given information on how to use. At that time they have not been used. Much like in the way that the import statement in Java. Most categories of the need to import about the use of before, but only import statement does not mean that this category has been used. Each creator and converter are id attributes in order to use the back.
DWR to identify the use of reflection should be used in the conversion type. Sometimes the type of information is not clear, then you can write a method to define the type of signature.
paragraph signatures to make the collection DWR to determine the type of data storage. For example, the definition of the following list we can not know in what type of store.
public class Check
public void setLotteryResults (List nos)
paragraph) signatures allow us to suggest that DWR should be used to deal with what type. Format of generic JDK5 in order to understand the people it is easy to understand.
<! [CDATA [
Check.setLotteryResults (List <Integer> nos);
</ signatures> DWR also a special parser to do this, so even if your environment JDK1.3 DWR can work properly.
Analysis of the rules and you are basically expected the same rules (with two exceptions), so the following types of java.lang will be the default import.
The first is the parser DWR1.0 in the bug, in some circumstances can not return the correct type. Let it be so you do not have the.
The second is when the parser "sunshine (sunny day)" resolver. That is to say it is very relaxed, as the compiler does not want to assure you of strict right. So sometimes it will also allow you to loss of import:
<! [CDATA [
Check.setLotteryResults (List <Integer>);
</ signatures> future version of DWR will use a more formal parser, the compiler will be based on the definition of the official Java, so you'd better not use too many things that do not strictly.
paragraph signatures only parameter used to determine the type of generic parameters. DWR will use their own reflection or run-time type of mechanism to determine the type, or the assumption that it is a String type. Therefore:
Does not require signatures - there is no generic parameters:
public void method (String p);
public void method (String  p); the need for signatures - DWR reflection can not be determined:
public void method (List <Date> p);
public void method (Map <String, WibbleBean> p); do not need signatures - DWR can guess the right:
public void method (List <String> p);
public void method (Map <String, String> p); do not need signatures - DWR can determine the type of run-time:
VI: dwr.xml more than dwr.xml document can have multiple files (For more information, see web.xml file). The definition of each document will be added together. DWR to use this function to load the configuration file basis. We can look at the standard configuration file to understand the content of dwr.xml.