JAVAEE--BOS logistics project 08: Configure proxy objects to remotely call crm services, view the partitions included in a specific area, view the associated customers of a specific area, javaee Logistics Project

Source: Internet
Author: User

JAVAEE--BOS logistics project 08: Configure proxy objects to remotely call crm services, view the partitions included in a specific area, view the associated customers of a specific area, javaee Logistics Project
1. LearningPlan

1. Target customers

N improve customer query methods in CRM services

N configure proxy objects in the BOS project to remotely call the crm Service

N adjust the customer page for a specific region

N achieve zone-based connected customers

2. view the partitions contained in the Zone

N page Adjustment

N server implementation

3. view the list of customers associated with a specific region

N page Adjustment

N the server remotely calls the CRM service activity customer information through the proxy object

 

 

2 Target customers2.1 Configure proxy objects in the BOS project to remotely call crm

Step 1: Introduce the CXF dependency in the pom. xml of the BOS Project

        <dependency>            <groupId>org.apache.cxf</groupId>            <artifactId>cxf-rt-frontend-jaxws</artifactId>            <version>3.0.1</version>        </dependency>        <dependency>            <groupId>org.apache.cxf</groupId>            <artifactId>cxf-rt-transports-http</artifactId>            <version>3.0.1</version>        </dependency>

Step 2: Use the wsimport command to parse the wsdl file to generate local code. Only interface files and object classes are required.

 

 

Step 3: register the crm client proxy object in the spring configuration file

<! -- Register the crm client proxy object --> <jaxws: client id = "crmClient" serviceClass = "com. itheima. crm. ICustomerService "address =" http: // 192.168.115.89: 8080/crm_heima32/service/customer "/>

 

Step 4: inject proxy objects to Action through Annotation

 

 

2.2 Improve Customer query methods in CRM services

L expand two methods in crm service interfaces

 

 

L implementation methods in implementation classes

// Query the public List of customers not associated with a specific zone <Customer> findListNotAssociation () {String SQL = "select * from t_customer where decidedzone_id is null "; list <Customer> list = jdbcTemplate. query (SQL, new RowMapper <Customer> () {public Customer mapRow (ResultSet rs, int arg1) throws SQLException {int id = rs. getInt ("id"); // obtain the value String name = rs from the result set based on the field name. getString ("name"); String station = rs. getString ("station"); Str Ing telephone = rs. getString ("telephone"); String address = rs. getString ("address"); String decidedzone_id = rs. getString ("decidedzone_id"); return new Customer (id, name, station, telephone, address, decidedzone_id) ;}}); return list ;} // query the public List of customers associated with the specified region <Customer> findListHasAssociation (String decidedzoneId) {String SQL = "select * from t_customer where decidedzone_id =? "; List <Customer> list = jdbcTemplate. query (SQL, new RowMapper <Customer> () {public Customer mapRow (ResultSet rs, int arg1) throws SQLException {int id = rs. getInt ("id"); // obtain the value String name = rs from the result set based on the field name. getString ("name"); String station = rs. getString ("station"); String telephone = rs. getString ("telephone"); String address = rs. getString ("address"); String decidedzone_id = rs. getString ("decidedzone_id"); return new Customer (id, name, station, telephone, address, decidedzone_id) ;}}, decidedzoneId); return list ;}

Note: The server expands the new method and the client needs to regenerate the client code.

 

2.3 Adjust the customer page

WEB-INF/pages/base/decidedzone. jsp

 

 

 

Step 1: Modify the associated customer button on the custom page and bind the event handler Function

Function doAssociations () {// obtain all the selected rows in the current data table and return the array var rows =$ ("# grid "). datagrid ("getSelections"); if (rows. length! = 1) {// The prompt $. messager. alert ("" appears. "select a zone for operation! "," Warning ");} else {// selected a fixed area $ ('# mermerwindow '). window ('open'); // clear the drop-down box $ ("# noassociationSelect "). empty (); $ ("# associationSelect "). empty (); // send an ajax request to request a specific Action. In a specific Action, the crm proxy object is used to remotely call the crm service to obtain the customer data var url_1 = "decidedzoneAction_findListNotAssociation.action "; $. post (url_1, function (data) {// traverse the json array for (var I = 0; I <data. length; I ++) {var id = data [I]. id; var name = data [I]. name; var telephone = data [I]. telephone; name = name + "(" + telephone + ")"; $ ("# noassociationSelect "). append ("<option value = '" + id + "'>" + name + "</option>") ;}}); // send an ajax request, request a specific Action. In a specific Action, the crm proxy object is used to remotely call the crm service to obtain the customer data var url_2 = "decidedzoneAction_findListHasAssociation.action"; var decidedzoneId = rows [0]. id; $. post (url_2, {"id": decidedzoneId}, function (data) {// traverse the json array for (var I = 0; I <data. length; I ++) {var id = data [I]. id; var name = data [I]. name; var telephone = data [I]. telephone; name = name + "(" + telephone + ")"; $ ("# associationSelect "). append ("<option value = '" + id + "'>" + name + "</option> ");}});}}

 

Step 2: inject a crm proxy object into a specific Action and provide methods to remotely call the crm Service

 

 

 

Step 3: bind events to the left and right buttons in the associated customer window

 

 

 

Step 4: bind an event to the "associated customer" button in the customized associated customer window

 

 

2.4 How to expand a region-specific associated customer on the crm Server

 

Note: After the crm Server Extension method is used, the bos client needs to regenerate the client code.

 

2.5 Provide the associated customer method in a specific Action

 

3 View partitions contained in a specific zone

WEB-INF/pages/base/decidedzone. jsp

 

3.1 Page Adjustment

Step 1: bind a data event to the datagrid

 

 

Step 2: Define the doDblClickRow Function

 

 

3.2 Server implementation

L provides a method in the partition Action to query the associated partitions Based on the partition id

 

 

L provide methods in SubareaServiceImpl to query the associated partitions based on the specific region id

 

 

 

4 View associated customer information in a specific region

 

    public String findListHasAssociation(){        List<Customer> list2 = customerService.findByHasAssociation(model.getId());        ObjectToJson(list2, null);        return NONE;    }

 

 

 

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.