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.