DWR understanding of DATA (or call back List.Set Ways Map of java)

Call Return List, Set or Map of the java method
1, dwr.xml configuration
Configuration with 4.1

<dwr>
<allow>
<create creator="new" javascript="testClass" >
<param name="class" value="com.dwr.TestClass" />
<include method="testMethod6"/>
</create>
<convert converter="bean" match="com.dwr.TestBean">
<param name="include" value="username,password" />
</convert>
</allow>
</dwr>

Note: If the List, Set or Map of the elements are simple types (including its package type) or String, Date, and the collection of an array type, you do not need to tag <convert>.
2, javascript call (to return to List as an example, List the elements TestBean)
First of all, the introduction of javascript script
Secondly, the preparation of java method call javascript function and receive the return value of callback function

Function callTestMethod6(){
      testClass.testMethod6(callBackFortestMethod6);
}
Function callBackFortestMethod6(data){
     // Where date receive method's return value
// The return value for JavaBean, there are two ways to handle
             // Don't know the name of the attribute, use the following method
           for(var i=0;i<data.length;i++){
for(var property in data){
                  alert("property:"+property);
                  alert(property+":"+data[property]);
               }
}
// Know the name of the attribute, use the following method
for(var i=0;i<data.length;i++){
               alert(data.username);
               alert(data.password);
}
}

Original: http://i.mop.com/gabriel80/blog/2008/01/10/6075031.html

分类:AJAX 时间:2009-05-24 人气:837
分享到:
blog comments powered by Disqus

相关文章

  • Xblo(JSP+Servlet+JavaBean+Oracle单用户Blog) 2012-03-09

    程序名称:Xblo(JSP+Servlet+JavaBean+Oracle单用户Blog) ================================================================ 程序版本:0.1(20100912) ================================================================ 程序说明: Xblo取自Xblog,由于只是个半成品以及为了避免重名,故舍掉最后一个g. ==========

  • map, set, list, such as a collection of JAVA in the analysis [reproduced] 2010-03-29

    Java TM 2 Platform Standard Ed. 5.0 The util package in JAVA there are two sets of the parent interface for all Collection and Map, they are the father and son relationship: java.util + Collection This interface extends from the - java. Lang.Iterable

  • underscore:get elements counts of a array 2013-12-07

    get elements counts of a array by underscore source code: function get_counts_of_the_elements_in_an_array(array){ var count = _.groupBy(array); var new_array= []; for(key in count){ new_array.push({'value':key,'count':count[key].length}) } return _.s

  • Recursive traversal of all elements of Java XML 2010-11-16

    import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.dom4j.tree.DefaultAttribute; /** * Java R

  • map, set, list, such as a collection of JAVA in the analysis (understanding) 2010-08-31

    The util package in JAVA there are two sets of parents all the interfaces Collection and Map, their father-son relationship: java.util + Collection This interface extends from - java. Lang.Iterable Interface + List Interface -ArrayList class -LinkedL

  • Access to the most n elements of the integer array list with the greatest product in the making of n-1 2010-10-23

    Old code, the first Tieshanglai, to be finishing package cn.ustc; import java.util.List; public class MaxArray{ /** * getMax Methods used to obtain the best elements of an array of integers n list Made with the greatest product in the n-1 个 * Element

  • Large elements of Java programming 30 2011-01-13

    (1) the class name first letter should be capitalized. Fields, methods, and object (handle) of the first letter should be lowercase. For all identifiers, which contains all the words should be close together, and capitalized the first letter of the w

  • My blog address Sina JAVA technology 2010-04-14

    My Sina JAVA technology blog address: http://blog.sina.com.cn/JiangxiFandunyang These are the problems encountered in my work record; conducive to normal again, when faced easily accessible;

  • java 集合类Array.List.Map区别和联系 2015-02-27

    java集合类主要分为以下三类: 第一类:Array.Arrays 第二类:Collection :List.Set 第三类:Map :HashMap.HashTable 一.Array , Arrays Java所有"存储及随机访问一连串对象"的做法,array是最有效率的一种. 1. 效率高,但容量固定且无法动态改变. array还有一个缺点是,无法判断其中实际存有多少元素,length只是告诉我们array的容量. 2.Java中有一个Arrays类,专门用来操作array .

  • Java Coding Standards (The Elements of Java Style) 2010-04-03

    Genaral Principles generally agreed 1.Adhere to the style of the original. Maintain the original style. 2.Adhere to the Principle of Least Astonishment. Compliance with the principle of least surprise. 3.Do it right the first time. For the first time

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.056 (s). 11 q(s)