This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 我在思考如何在一个通用的web app framework 中加进web page data validation rules. 如何定义required field? 如何定义specific validation rule, ( such as: if... elseif...else....end if ) 大家有什么好主意?
-nicetomeetyou(_);
2009-2-22
(#5066564@0)
-
即便是牛年,也不要这样牛劲冲天嘛。今天是 SUNDAY, GET A LIFE!
-townsl(风筝);
2009-2-22
(#5066575@0)
-
这就去auto show, 网上订票优惠10%..;-)
-nicetomeetyou(_);
2009-2-22
(#5066579@0)
-
use javascript to define the rules and dynamically execute it in runtime
-anthonylo2008(anthonylo);
2009-2-22
(#5066865@0)
-
I do have a admin process to register stylesheet in database, since this is a database-driven framework. Each stylesheet has a set of local variables, its own CSS, its own resource sheet. I will do this way for data validation:(1) Register required field for the style sheet in database.
(2) Read table metadata to get each field's data type.
(3) Store general rule ( such as validating email address, phone number, datetime format ) in a XML file on server.
(4) Store style sheet specific data validation rules in a resource file using BPML.
-nicetomeetyou(_);
2009-2-22
{319}
(#5067697@0)
-
我能想到的2种:1. client-side直接通过javascript function来做 or 2. ajax来call webservice的method。
-mfcguy();
2009-2-22
(#5067865@0)
-
(1) Using JS for data validation is definitely true. (2) If for example, an email field is on the page, using ajax's round trip to validate "@" is not necessary. My frustration is how to write a general scheme to dynamically ...create JS code and then let it to work on client side alone.
I have already finished a general method for form data submission. All system has to know is SQL statement, that is all. database table, style sheet, etc, share the same namespace. Internal SQL analyzer will do the work smartly.
-nicetomeetyou(_);
2009-2-22
{292}
(#5068363@0)
-
why would you need to dynamically create JS? just program the rules in JS and store it with your custom fields in your data storage, pass the JS to client side and then run it. that way you make it dynamic.
-anthonylo2008(anthonylo);
2009-2-22
(#5068460@0)
-
For a simple app with tens of pages, it is OK to program JS for each page, each event. For more complex ERP, for example, ECR app, one request may generate tens of secondary ECRs. Data validation isvery complicated with many business rules (workflow status check, approver status check, approval process check, etc. ) getting involved, and most of them have to be done on server side. Data validation on server is OK, and is a prevailing way nowadays......But what I would like to do is to create JS on the server side based on rules already known, and submit it with html page together, let client side do the job without network traffic....it is possible.
-nicetomeetyou(_);
2009-2-22
{459}
(#5068576@0)
-
no, you got my idea wrong.for example, you can define a validation rule in JS like:
return ($thisField != "" && $field_001 > 100 && $field_002 < 50);
well, this rule can be reused across different fields and even different pages.
and yes, in this example, you can say the above script is just a template, you still need to instantiate it for the real executable.
all depends on how you design it. hope it makes sense for you.
-anthonylo2008(anthonylo);
2009-2-22
{418}
(#5068598@0)
-
You are right, that is a good example for template. this can be designed as a normal stylesheet and included into main style sheet (or JSP), specific field names will be transferred through params. Thanks!
-nicetomeetyou(_);
2009-2-22
(#5068612@0)
-
If you are using .net, you could use validatation controls(there are several different types of : required,ranged,regular-expression,custom etc) which is server-side control but rendered to client-side as javascript code.
-mfcguy();
2009-2-23
(#5068683@0)
-
Sorry, I don't know .net. Forgive this idiot:-)
-nicetomeetyou(_);
2009-2-23
(#5071424@0)
-
for those pattern-based validations, just simply use the Regular Expression. only for those more complex logics or customizable logics, JS can kick in offering convenience.
-anthonylo2008(anthonylo);
2009-2-22
(#5068473@0)
-
I may define rules in a xml file and use a javascript to interpret those rules. Those two are generic. A second javascript will be used to bind rules onto pages and enforce them. Relationship between rules can be enforced in same javascript.
-liquid(豆泡松果 之 松果豆泡);
2009-2-22
(#5068641@0)
-
Interesting, more details please?
-nicetomeetyou(_);
2009-2-23
(#5071440@0)
-
Actually if a programmer uses ajax a lot, that would be a nightmare to system architect. One case: A new feature needs to be added in a webpage, then a button is added, the rest of things are done by JS, ...
-nicetomeetyou(_);
2009-2-23
{663}
(#5069514@0)