DWR Ext Load Data _extjs

Source: Internet
Author: User
One, the direct use of DWR in ext
The 1,pojo Manager class is
Copy Code code as follows:

public class Customermanagerimpl extends Hibernatedaosupport implements Customermanager {
Public Pagemodel allcustomers () {
Pagemodel Pagemodel = new Pagemodel ();
List datas = new ArrayList ();
int total;

String hql = "from Customer";
Datas = This.gethibernatetemplate (). Find (HQL);
String counthql = "SELECT count (*) from Customer";
Total = ((Long) this.getsession (). CreateQuery (COUNTHQL). Uniqueresult ()). Intvalue ();

Pagemodel.setdatas (datas);
Pagemodel.settotal (total);
return Pagemodel;
}
}

2, then direct call to Dwr to get the data (Dwr.xml Code reference later)
Copy Code code as follows:

var store = new Ext.data.Store ({
Data: ... Here's a dwr call directly get
Reader:new Ext.data.JsonReader ({ID: "sn"},fields),//list data
Sortinfo:{field: ' Name ', direction: ' ASC '}//sort info
});

Dwr+ext integrated sentences, Store.loaddata (dataslist); Loading data
Data returns the Pagemodel class, the property is Total,datas (list data type)
There's no need to create a function to execute directly
Jcustomermanager.allcustomers (function (data) {
var total = data.total;
var Dataslist=data.datas; Data is List type
Store.loaddata (dataslist); Loading data
});

3, here's the DWR only do one thing, through the anonymous function, will return the value of the list data directly injected to the store. The data returned by DWR can be read directly by Jsonstore, and we need to set the corresponding fields parameters to tell Jsonreader what properties are required.

4, supplemental Dwr.xml code
Copy Code code as follows:

<dwr>
<allow>
<!--dwr+spring injection mode-->
<c reate creator= "Spring" javascript= "Jcustomermanager" >
<param name= "Beanname" value= "Customermanager"/> The class used by the
</create>
<!--uses the converter-->
<convert match= "Com.graduate.crm.PageModel converter=" Beans ></convert>
<convert match= "Com.graduate.crm.model.CompanyCustomer" converter= "Bean" >< /convert>
</allow>
</dwr>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.