[Prodinner project] learning and sharing _ Part 4 (conclusion) _ controller layer (Controller)

Source: Internet
Author: User

Controller function:

After the data is queried from the database, a result set is filtered out based on certain business logic. The final purpose of this result set isDisplayed on the page.

Controller is used to call out the result set of the business logic layer, and then return the result set to the view (PAGE) through model or JSON.

1. We need to create a conroller to inherit the encapsulated basecontroller.

 

2. instantiate the previously written personservice.

 

3. Obtain the result set.

-Crudservice is encapsulated in personservice. Common Methods for adding, deleting, modifying, and querying are also available. We also use isunique as a custom method in section 3.

 

4. Return the result set to the page

-The JSON method is popular nowadays because of data transmission. Here we will talk about JSON. Other methods are also available. You can try it on your own.

 

5. View acceptance

-Call the action of the background controller in view. We recommend that you useAjaxMethod, as shown below,

Through Ajax, if a userid value is passed, the user can determine whether the user is unique.

If no parameter is passed, the system returns the JSON set of all users.

6. Ajax calls the Controller Method

-Here I use Ajax encapsulated by extjs, or jquery.

Ext. ajax. request ({URL: "person/Index", // action path async: false, method: 'post', datatype: "text", // data type Params: {userid: UID // passed parameter}, success: function (result) {// The returned result is automatically placed in resut with alert (result. responsetext) ;}, failure: function () {alert ("failure ")}});

7. The result set can be displayed on the page as you have designed it.

 

8. prodinner has a lot of well-designed pages, tables, and buttons. You can try them all at the official documentation.

-I should support IE8 in my current project, but some pages of prodinner are designed to be incompatible with IE8, so I will learn it here,

I will have the opportunity to use it in the future. I will try again later.

 

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.