Rule Engine in JavaScript [closed]

£可爱£侵袭症+ 提交于 2019-11-30 11:05:06

JSR-94 is a Java specification, so I don't see what it has to do with the browser.

There's Google JSON rules:

http://code.google.com/p/jsonrules/

You said you tried the AJAX route. Does that mean a rules engine running on the server and an asynch call to access it?

This is a valid question. From this article, JSR 94

does not standardize the following: The rule engine itself The execution flow for rules The language used to describe the rules The deployment mechanism for Java EE technology

Thus, it may be possible to use a DSL that could be executed on the client and server, and this could be developed, executed, and managed as per the JSR 94 architecture. Or not.

Another article Creating a simple rules engine using the Java scripting API employs JSR-233 plus other stuff to create a rule engine system. This however predates the JSR 94.

I got to this stackoverflow page since I too was looking for a solution. Currently, I have a page to validate on client side where groups of fields can trigger different validation rules, and requirements are changing. To write this in imperative code just creates a mess with high cyclomatic complexity.

However, the easiest thing to do is use one of the many JavaScript form validation libraries out there. Still looking.

Since the javascript lives in the browser, it's fairly easy for a user to check your source code and bypass any js validation mechanisms. That's why it's usually done server-side.

It's a pain but I usually implement validation both in javascript and on the server, that way "normal" users will have a quick response, and "hackers" will be kept out of the system. Unfortunately I think that's the way you need to go if you want both good user experience and good security.

To answer your question, to my knowledge there's no common library that can be used both on the client side and the server side.

PS. remember JavaScript is not Java ! :-) http://en.wikipedia.org/wiki/JavaScript#JavaScript_and_Java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!