Java Project accumulation--unified check of front page

Source: Internet
Author: User

In the project, we are faced with the problem, that is, if the foreground to do abstract, we think of the background code abstraction, we are familiar with, but the foreground of abstraction, how do we do it? I am afraid that this problem, if it is the first time to throw themselves, they are also very frightened, that is, we do not correspond to a business to write a page? Never thought of abstract, here, I would like to say, that is our most elementary way, today to take everyone together to witness a more reliable way!

Review

We review the process of HTML coding, In the web1.0 era, we are mostly static pages, this time, can be displayed on the good, due to the limitation of Internet speed, the constraints of computer processing ability, we can only write everything together, but over the years, technological innovation, speed improvement, personal computer and server technology upgrade, allowing us to display dynamic pages, at this time, we call It is web2.0!

In the web2.0 era, we can do more, can do a lot, CSS, although not web2.0 representative technology, but he gave us the idea is that the Page object, the style as a class exists, the carrier of this class is a CSS file, and each time we write the class attribute is in the instance of the object, so Technology, gives us a big inspiration, we can also be a lot of concepts to peel off HTML, do abstraction and encapsulation, packaged into a class it? The answer, of course, is yes!

Today, I found in our project, the existence of cattle, the reason why cattle, he found a concept of abstraction, is a unified verification of the JS code, plainly, is that we do not need to write too much conventional length, character verification, these unified by a class to complete, we see how he realized!

class file: Validateform.js

Comparison:1, previous page validation code

<span style= "FONT-SIZE:18PX;" >//in order to verify that the medical number is empty  var isDBNull = ' true '  //To determine if the doctor's number is empty, is null: true, otherwise false;  function Isinoputnull () {for (Var i = 0;i < detailsourcelist.length; i++) {                  var datestr = $ (' #txtOriginalCode ' + i) [0].value;          if (datestr.trim () = = ") {isdbnull= ' false ';}}  } </span>


So that every page that we need to verify is going to go through this function at commit time, if we verify more, we will write n similar function in the submission form, so the actual waste is our time!

2, after the improvement


<span style= "FONT-SIZE:18PX;" ><input type= "text" vtype= "Numandstr" notnull= "true" vdisp= "hint info" id= "Isoldleader"   value= "${ Loginuser.nleader} "/></span>


In submitting the form, we only need to invoke a uniform authentication entry (dovalidate).


Summary:

Front page of the package, in fact, to reduce the number of code personnel development, to do a development, multiple reuse of the effect, such development, there are many, such as Date control, button control, there is a level of encapsulation, is the dynamic combination of the front page, is a development template page, multiple use, Plainly is the background combination of the page, to the front desk, such an example, I wrote earlier in the blog, we can go to see "on the road-the integration of Factory mode and decoration mode"

encapsulation, in my opinion today, nothing is absolutely not to encapsulate, we found that the original system is, think this is special, that is special, actually we are unfamiliar with the business, in the system, we also found that the system to achieve half, suddenly found that there are many things can be encapsulated, we do not have to upset , this is the experience, we have a certain type of business packaging, but also from scratch, accumulated a certain code and business, we can use the existing giants, is the network, in the system before you may wish to look at how others do, we will be very inspired!


Accessories: Background Click JS Download


Java Project accumulation--unified check of front page

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.