Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the data validation of Swing applications?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what is the data verification of Swing application, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

This period of time is really extremely busy, on the one hand, to develop the system framework of the company's project, to divide the project into different sub-projects, to write core code; on the other hand, to introduce extreme programming (XP) into team development, deploy all kinds of XP services such as subversion, ant+ivy, Hudson, and so on. By the way, ubuntu is really not generally easy to use. It is suggested that all those who have the ability should be transferred to ubuntu for development.

The client of the framework I am currently developing is a fat client, that is, the Swing client. Swing applications have many advantages over Web applications because they are fatter. Data validation is one of them. Of course, today's Web applications are much better than before by using Ajax, but you still can't avoid sending requests to the service segment when validating data, at least you can't avoid the process of transferring the verification results from the Web server to the user's browser. Fat clients like Swing can verify the data completely locally, and even continue to work off the network (this is also an important topic in the research and development of Web applications).

Some time ago, I developed a general data verification module that can be applied to all Swing applications. It is found that after it is used in the project, programmers hardly need to code for ordinary data verification, and the efficiency is improved a lot. So I wrote a blog post and shared it with you. The original text is written in English.

Many different open source frameworks and class libraries are used to write this module, one of which is JXLayer. After the article was finished, I went to invite Alexp, the author of JXLayer, to give me some advice, and then started a discussion at the back of my article. It was interesting that he was a great man in Swing team. Great! He he.

Ok, let's get back to the subject of today's article. The main purpose of today is to translate my English blog into Chinese (I will not translate my article word for word, I will not translate it word by word, but may also have a discussion with you). I hope you can benefit from it, and I also hope that you can meet friends with literature and make friends. Cut the nonsense and get to the point.

Data validation (Validation) has always been a very important part of software development, with it, your system will make customers feel more friendly, and your system will be protected to a certain extent. In general, data validation can be done on both the client side and the server side. The default JSF data validation is on the server side, where the data can only be validated after it has been submitted, and then the error message is passed back to the user's browser. Later, after the large-scale use of Ajax, we can basically achieve "instant" verification of the modified data. Note that this is an instant in quotation marks, and the data actually has to be transferred between the browser and the server, but Ajax changes this transmission to implicit, which in theory does not really achieve (off-network) instant verification. This can be achieved in Swing applications.

In fact, when developing Swing applications, data verification has always been tricky. There are too many places that need to be manually coded, and the efficiency is not high. Later, after the combination of JGoodies Validation and JGoodies binding, it was better. This JGoodies Validation can achieve both model-level verification and Bean-level verification, but after years of use, it is found that it is more suitable for small and medium-sized projects, and the code to be written is no less than that written manually.

After JGoodies became popular for a while, sun began to launch its own bean binding scheme: beansbinding (JSR 295), which I personally feel is easier to use than JGoodies binding (JGoodies's author Karsten is also on the expert group, a man I have worked with before, and I have a photo with him in msn space, and he is definitely an awesome person in the world of Swing). This beansbinding also provides data validation, but this data validation only works after the target has been changed and before the data is synchronized back to source. It is limited to use and has a large amount of coding.

Since most of the current projects are based on POJO, Hibernate validator has provided a good data validation framework, we do not need to reinvent the wheel, we should try to stand on the shoulders of giants, so that we can stand higher and see further. So I considered developing data validation with beansbinding and Hibernate Validator. There is another important problem, that is, when the data is wrong, we need to display the corresponding information in the user interface, such as Error icon and error prompts. I consider using JXLayer.

Thank you for reading this article carefully. I hope the article "what is the data validation of Swing applications" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report