dwr configuration file dwr.xml

2009-06-26  来源:本站原创  分类:AJAX  人气:1008 

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:

"- / / GetAhead Limited / / DTD Direct Web Remoting 1.0 / / EN"


<! - Init is only needed if you are extending DWR ->
</ init>

<! - Without allow, DWR isn't allowed to do anything ->
<create creator="..." javascript="..."/>
<convert converter="..." match="..."/>
</ allow>

<! - You may need to tell DWR about method signatures ->
</ 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.

A: <allow>
allow the definition of paragraphs inside the DWR can create and test the type of conversion.

Second: Creators
dwr.xml elements create document is structured as follows:

<create creator="..." javascript="..." scope="...">
<param name="..." value="..."/>
<auth method="..." role="..."/>
<exclude method="..."/>
<include method="..."/>
</ create>
</ allow> here most of the elements are optional - you really must know is that the designation of a creator and the name of a javascript.

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.

javascript attribute to specify the browser was created by the name of the object. You can not use Javascript keywords.

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.

<create creator="new" javascript="Fred">
<param name="class" value="com.example.Fred"/>
<include method="setWibble"/>
</ 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:

<create creator="new" javascript="Fred">
<param name="class" value="com.example.Fred"/>
<auth method="setWibble" role="admin"/>
</ create>
-------------------------------------------------- ------------------------------

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:

<create creator="new" javascript="Blah">
<param name="class" value="java.util.Date"/>
</ create>
</ allow> the code java.util.Date mapped to Javascript, and named Blah, so when you call Javascript in Blah.toString (reply) then a new java.util.Date will be through the default constructor created, and then toString () method is called, and then the resulting data back to the reply method (in this case is the date string format).

-------------------------------------------------- ------------------------------

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:

<create creator="script" javascript="EmailValidator">
<param name="language" value="beanshell"/>
<param name="script">
import org.apache.commons.validator.EmailValidator;
return EmailValidator.getInstance ();
</ param>
</ create>
</ 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.

The SpringCreator
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:

<create creator="spring" javascript="Fred">
<param name="beanName" value="Shiela"/>
</ create>
</ 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>
</ context-param>
</ listener-class>
</ 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:

<create creator="spring" javascript="Fred">
<param name="beanName" value="Shiela"/>
<param name="location" value="beans.xml"/>
</ create>
</ 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:

<create creator="jsf" javascript="ScriptName">
<param name="managedBeanName" value="beanName"/>
<param name="class" value="your.class"/>
</ create>
</ 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>

<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.

-------------------------------------------------- ------------------------------

Struts integration
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:

<create creator="struts" javascript="ScriptName">
<param name="formBean" value="formBeanName"/>
</ create>
</ 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:

<create creator="pageflow" javascript="ScriptName"/>
</ 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
session.setAttribute (yourBean)
. 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

Array Converter
Bean and Object Converters
Collection Converter
Enum Converter
DOM Objects
Hibernate Integration
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

Date Converter
Date Converter in Javascript type of Date of Date with the Java type (java.util.Date, java.sql.Date, java.sql.Times or java.sql.Timestamp) conversion between. Converters with the same base, DateConverter default is support.

If you have a Javascript string (for example, "01 Jan 2010"), you want it converted to the Date type of Java there are two ways: in the javascript using Date.parse () to resolve it into a Date type, then DateConverter passed to the DWR server; or as a string passed to the Server, and then Java in SimpleDateFormat (or similar) to resolve.

Similarly, if you have a Java type of Date and want to use it in HTML. You can use SimpleDateFormat to convert it to use string. Date mass directly to the Javascript, and then use the Javascript format. The first number is simple, although a waste of your converter, but to do so will be displayed on the browser logic is limited. In fact, a better way behind, there are some tools can help you, such as:

The Javascript Toolbox Date formatter
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.

IV: <init>
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.

5: <signatures>
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 [
import java.util.List;
import com.example.Check;
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 [
import java.util.List;
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:

public List <Date> method (String p); there is no need to enable Javascript in all the key objects are String types - you can use other types as the key. But before they will be converted to type String. DWR1.x with the key characteristics of Javascript into a String. DWR2.0 may toString () method, in the service section of the conversion.

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.

  • dwr configuration file dwr.xml 2009-06-26

    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 confi

  • dwr configuration file dwr.xml Explained (change) 2010-04-12

    dwr.xml is the DWR configuration file. By default, it should put it in WEB-INF directory (web.xml directory) to create dwr.xml file dwr.xml file is structured as follows: <dwr> <! - Init is only needed if you are extending DWR -> <init>

  • dwr configuration file web.xml Xiangjie (change) 2010-02-14

    1, the minimum configuration java Code: <servlet> <servlet-name> dwr-invoker </ servlet-name> <servlet-class> uk.ltd.getahead.dwr.DWRServlet </ servlet-class> </ servlet> <servlet-mapping> <servlet-name> dwr

  • DWR configuration file name and path set 2010-11-15

    Some people may like the design process DWR configuration file will be named as their favorite name, or under the authority might be possible to read the different profiles, how to do it? 1, assuming that I will DWR configuration file named "MyDwr.xm

  • Xiang Jie Struts configuration file, web.xml and struts-cofig.xml, as well as the struts-cofig.xml in the role of the various labels 2010-04-19

    Struts applications use two XML-based configuration files to configure, respectively web.xml and struts-cofig.xml file. Web.xml file is the configuration for all web applications, while the struts-config.xml file is struts-specific configuration file

  • Help Documentation-dwr.xml DWR configuration file 2010-10-27

    Maybe my friends will think this is what the official release of DWR help, but sorry it is not. DWR is now a lot of friends in the use of development projects, I am one of them, but suffer on the DWR's Help documentation is too small, many problems h

  • DWR configuration file specification 2010-10-02

    DWR.xml configuration file specification 1, the establishment of a dwr.xml dwr.xml profile of any documents are the declaration needs to include DWR DOCTYPE line in the following format: <! DOCTYPE dwr PUBLIC "- / / GetAhead Limited / / DTD Direct

  • dwr configuration file description 2010-12-17

    dwr.xml Format: <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd"> <dwr> <init> <creator/> <converter/> </init> <allow> <

  • Struts2.0 configuration file (web.xml) 2010-04-19

    web.xml is the web application loads the important information about servlet configuration file, play initialization servlet, filter, etc. The role of web programs. In general, all of the MVC framework for Web applications need to load a core control

  • maven2 configuration file pom.xml setting.xml 2010-02-04

    This article is mainly about maven2 core set of two documents with the understanding: pom.xml and setting.xml. pom.xml in folder to create the project, setting.xml maven package in the conf folder after extracting. Start with settings.xml, settings.x

  • Heritrix source code analysis (b) describes the configuration file order.xml 2010-11-21

    http://guoyunsky.javaeye.com/blog/613412 order.xml is the core of the Heritrix, each of which are related to the Heritrix a configuration of the operation, did not read until I can source the channel to learn from the limited use of these configurati

  • dwr in the configuration file dwr.xml - very important 2010-04-25

    In web.XML we set the servlet dwr, you can set some initialization parameters The most important thing is to debug parameter to set to true so that you can use the test / debug page dwr.xml documents: dtd document type definition, it will automatical

  • Struts configuration file struts-config.xml 2010-08-04

    Struts struts-config.xml is the core file, which can be configured to a variety of components. A simple struts-config.xml file <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE Struts-config PUBLIC "- / / Apache Soft

  • FLEX's RIA application configuration file (*- app.xml) description 2010-06-22

    <? Xml version = "1.0" encoding = "UTF-8"?> <application xmlns="http://ns.adobe.com/air/application/1.0"> <! - The application identifier string, unique to this application. Required. -> <id> AIRTest1

  • dwr configuration framework 2010-03-23

    What is DWR (Direct Web Remote)? DWR is an AJAX solution! DWR consists of a java library, and a set of javascript, so we can use a very simple way to use javascript in the page's java objects directly call back! DWR Architecture DWR's javascript libr

  • SSH configuration file architecture 2009-05-20

    SSH (Struts1.3 + Spring2.0 + Hibernate3.1) architecture configuration document briefly Contents 1. 2 Runtime Environment 2. Configuration 2 2.1 New Project 2 2.2 Add Struts framework supports 3 (1) add the Struts package and the setting up of the pat

  • Cart combat II: entity class and the hibernate configuration file 2009-07-27

    1. According to the above four tables set up, we Mr. category into four entities, namely: Account, Order, Item, Product Account as a result we will be in the city and the street into an abstract entity class Address, therefore, there is a category Ac

  • Chinese struts configuration file layout 2010-03-24

    A Java Web application configuration files: web.xml the application web.xml file is located in WEB-INF directory, and provides a WEB application configuration information. A relatively complete web.xml file is as follows: <? xml version = "1.0&quo

  • Nutch1.0 Getting Started (3) - load the configuration file 2010-03-27

    /** * I am also a starter, if not the correct place please advise . Thank you ! * Part of the contents of the reference from the Internet, such as bluntly , Please forgive me . *QQ:472429029 *Email:[email protected] **/ Nutch's configuration file

  • c # call the API to achieve the ini configuration file to read 2010-09-20

    When making application development, configuration management is essential. For example, the configuration database server, install and update the configuration and so on. Since the rise of Xml and now most of the configuration file is xml document t