锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品美女在线观看播放,亚洲激情视频网站,亚洲色大成WWW亚洲女子http://www.tkk7.com/RR00/category/19291.html涓嶈鍩嬪ご鑻﹀共錛岃瀛︿範(fàn)錛屽涔?fàn)锛屽啀瀛︿範(fàn)銆傘傘傘傘? <br> powered by <font color='orange'>R.Zeus</font>zh-cnWed, 28 Feb 2007 07:42:33 GMTWed, 28 Feb 2007 07:42:33 GMT60錛★吉錛★幾銆analyze from IBM develpershttp://www.tkk7.com/RR00/articles/94458.htmlR.ZeusR.ZeusWed, 17 Jan 2007 08:52:00 GMThttp://www.tkk7.com/RR00/articles/94458.htmlhttp://www.tkk7.com/RR00/comments/94458.htmlhttp://www.tkk7.com/RR00/articles/94458.html#Feedback0http://www.tkk7.com/RR00/comments/commentRss/94458.htmlhttp://www.tkk7.com/RR00/services/trackbacks/94458.html Implementing the catalog

The starting point of a DWR application is writing your server-side object model. In this case, I start by writing a DAO to provide search capabilities on the product catalog datastore. CatalogDAO.java is a simple, stateless class with a zero-argument constructor. Listing 1 shows the signatures of the Java methods that I want to expose to Ajax clients:



Listing 1. The CatalogDAO methods to expose via DWR
/**
 * Returns a list of items in the catalog that have 
 *  names or descriptions matching the search expression
 * @param expression Text to search for in item names 
 *  and descriptions 
 * @return list of all matching items
 */
public List<Item> findItems(String expression);

/**
 * Returns the Item corresponding to a given Item ID
 * @param id The ID code of the item
 * @return the matching Item
 */
public Item getItem(String id);

Next, I need to configure DWR, telling it that Ajax clients should be able to construct a CatalogDAO and call these methods. I do this with the dwr.xml config file shown in Listing 2:



Listing 2. Config to expose CatalogDAO methods
<!DOCTYPE dwr PUBLIC
  "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
  "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
  <allow>
    <create creator="new" javascript="catalog">
      <param name="class" 
        value="developerworks.ajax.store.CatalogDAO"/>
      <include method="getItem"/> 
      <include method="findItems"/> 
    </create> 
    <convert converter="bean" 
      match="developerworks.ajax.store.Item">
      <param name="include" 
        value="id,name,description,formattedPrice"/>
    </convert>
  </allow>
</dwr>

The root element of the dwr.xml document is dwr. Inside this element is the allow element, which specifies the classes that DWR will remote. The two child elements of allow are create and convert.

The create element

The create element tells DWR that a server-side class should be exposed to Ajax requests and defines how DWR should obtain an instance of that class to remote. The creator attribute here is set to the value new, meaning that DWR should call the class's default constructor to obtain an instance. Other possibilities are to create an instance through a fragment of script using the Bean Scripting Framework (BSF), or to obtain an instance via integration with the IOC container, Spring. By default, when an Ajax request to DWR invokes a creator, the instantiated object is placed in page scope and therefore is no longer available after the request completes. In the case of the stateless CatalogDAO, this is fine.

The javascript attribute of create specifies the name by which the object will be accessible from JavaScript code. Nested within the create element, a param element specifies the Java class that the creator will create. Finally, include elements specify the names of the methods that should be exposed. Explicitly stating the methods to expose is good practice to avoid accidentally allowing access to potentially harmful functionality -- if this element is omitted, all of the class's methods will be exposed to remote calls. Alternately, you can use exclude elements to specify only those methods you wish to prevent access to.

The convert element

While creators are concerned with exposing classes and their methods for Web remoting, convertors are concerned with the parameters and return types of those methods. The role of the convert element is to tell DWR how to convert datatypes between their server-side Java object representation and serialized JavaScript representation, and vice versa.

DWR automatically mediates simple data types between Java and JavaScript representations. These types include Java primitives, along with their respective class representations, as well as Strings and Dates, arrays, and collection types. DWR can also convert JavaBeans into JavaScript representations, but for security reasons, doing so requires explicit configuration.

The convert element in Listing 2 tells DWR to use its reflection-based bean convertor for the Items returned by the exposed methods of CatalogDAO and specifies which of the Item's members should be included in the serialization. The members are specified using the JavaBean naming convention, so DWR will call the corresponding get methods. In this case, I'm omitting the numerical price field and instead including the formattedPrice field, which is currency-formatted ready for display.

At this point, I'm ready to deploy my dwr.xml to my Web application's WEB-INF directory, where the DWR servlet will pick it up. Before proceeding, however, it's a good idea to ensure that everything is working as expected.



R.Zeus 2007-01-17 16:52 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 日韩在线免费播放| 国产亚洲精品美女久久久久| 国产gav成人免费播放视频| 午夜老司机免费视频| 国产成人免费a在线视频app| 国产AV无码专区亚洲AV手机麻豆| 亚洲精品制服丝袜四区| 亚洲成a人片在线不卡| 一级毛片a女人刺激视频免费| 91制片厂制作传媒免费版樱花| 亚洲国产综合AV在线观看| 一级特黄录像免费播放中文版 | 一本色道久久88亚洲综合| 亚洲AV人无码激艳猛片| 亚洲国产精品免费观看| 两个人看www免费视频| 国内自产少妇自拍区免费| 久久久久亚洲精品影视| 亚洲熟女综合一区二区三区| 999zyz**站免费毛片| 免费观看男人免费桶女人视频| 亚洲午夜福利在线观看| 看成年女人免费午夜视频| 国产成人精品久久免费动漫 | 狠狠久久永久免费观看| 亚洲国产亚洲片在线观看播放| 一级毛片完整版免费播放一区| 成人在线免费观看| 亚洲欧洲日韩在线电影| 无码精品一区二区三区免费视频| 亚洲国产日韩在线观频| 窝窝影视午夜看片免费| 国产成人在线免费观看| 国产尤物在线视精品在亚洲| 手机在线免费视频| 亚洲日本一线产区和二线产区对比| 午夜网站在线观看免费完整高清观看| 精品亚洲成α人无码成α在线观看 | 国产亚洲精品无码拍拍拍色欲| MM1313亚洲精品无码久久| 两个人看的www免费|