I'm going to get in the car later, so I won't continue to talk about the development process today. Let's talk about the background language issues that are generally of concern.
When learning Ext JS, the author has always emphasized that the central idea of learning is "the separation of interface and data". As long as you have a good grasp of this idea and a deep understanding of the operation process of Ext JS, you will not be troubled by what background language to use. It can be said that as long as the idea is clear, it is easy to migrate an Ext JS project to a different back-end language platform. Let's give a brief explanation using this example.
If you put down the burden of language and insist on reading the article in this example, you will have a feeling that there is only one file that combines the client script file and the backend language, which is the homepage index.cshtml. If all the scripts in this file are Extracted, basically, Ext JS has nothing to do with the development language platform. Copy the Scripts directory to any language platform project and you can use it directly. The modified place is basically the address. If you use Ext.Direct, this will be even more thorough. Basically, no modifications are needed, as long as the background language has corresponding methods. If this is clear, it will be easier to handle.
For example, if you want to modify this example to the Java version, if the Java architecture does not support authentication verification, split the homepage into two files, one is specifically for login, and the other is the page to jump to after login. The method is probably commonplace for those who are familiar with web development.
In Ext JS, there are three main ways to submit data:
1. Form submission. Although this method also uses Ajax, the background processing is no different from the basic form submission. Therefore, the background data processing method is not difficult, you know! don't know? This... let's brush up on our HTML knowledge. The best example of this is the submission of the login window. You can try to practice in a language you are familiar with.
2. Submission in Ajax form. The example here is the reset password in user login. Although the data format is not fixed, the submission parameters have been defined by yourself or the project. The background data processing method is different from the data submitted by the form. big.
3. Store synchronization data submission method, as long as the Writer is defined and the same data submission method is used, the background data processing method is basically the same. For example, for add, edit, and delete operations in user management, the submitted data must be extracted from the data keyword, and then the submitted data needs to be converted into a JSON array through the parse method of the server-side JSON object, and then the specific data object must be extracted. deal with. The processing of Java can basically be handled by referring to Section 1.2.6 in the book. For other languages, you can find corresponding JSON libraries for processing.
In Ext JS, the return format of data is basically fixed. In the example, there are currently two return formats:
1. Form error message:
{
Success: true or false,
errors: {
field1: "Error message",
field2: "Error message",
...
}
}
2. Other data
{
Success: true or false,
total: total number of data,
Data : [...],
Msg : "Error message"
}
In the example, whether it is the synchronization operation of the Store or the submission of Ajax data, the second data return format is used, which is basically universal.
Once you understand the Ext JS data submission format and return format, you will know how to extract and return data. As long as the data is returned in the correct format, Ext JS can run normally without being affected by any background language. As for the backend, it doesn't matter what language or database to use. These are technologies that developers have already mastered. The rest is to return data according to the format. Therefore, it is not difficult to modify this example.
For example, to display user data, no matter what the structure of the data table is, after you extract the data from the database, you can organize the data and return it according to format 2. You said you don't know how to extract data from the database? This...this, I can't teach.
To add a user, first extract the data according to the submission format, and then use your own database adding data method to add the data to the database. According to the data return format 2, return the information of successful addition or failure to the client. It is that simple. The basic steps for editing and deleting are the same.
As for permission control, each language has its own way. The simplest one is to verify in the header of each operation method. If the verification finds that the permission requirements are not met, then return a success of false and Msg information according to the data return format 2. Just data that "you don't have permission to access".
After the data processing method is clear, the remaining thing is to make the data submission address of each operation of Ext JS correspond to the method in the server. This is not too difficult if you have a foundation in web development.
The above briefly introduces how to modify this example into versions in different languages. If there is anything you don’t understand, please leave a message to the author to discuss development methods in different languages. If you are interested in modifying this example into different language versions but have no idea where to start, you are welcome to contact the author and jointly modify this example into different language versions for everyone to learn from.