From: Barrie S. <ba...@ro...> - 2004-11-27 21:04:14
|
Anthony, Thanks for the response. My main problem was that I decided to use Groovy as a scripting language. Although BeanShell supports it, it was painfully slow (over 1.2 seconds per field on the page) I thought at first it may be a caching problem, but it was just the instantiation of BeanShell that was the issue. So I wrote a GroovyValidator that compiles and caches the class for reuse. It also allows you to specify an update-interval for checking to see if the script has changed. The time has dropped from 1.2 seconds to 10ms or less per field. Big difference. I'm attaching it for consideration of inclusion into FormProc. It's set up just like a regular script in formproc.xml except for the uodate-interval. <validator-map type="groovy" classnam e="org.formproc.validation.GroovyValidator"> <property name="script-root" value=""/> <property name="script-root-type" value="classpath"/> <property name="update-interval" value="-1"/> </validator-map> <shared-validator name="required"> <validator type="groovy"> <script>FieldRequired.gy</script> <error>Required Field</error> </validator> </shared-validator> It requires only three jars from Groovy: groovy-1.0-beta-7.jar asm-1.4.3.jar asm-util-1.4.3.jar and a sample script (the FieldRequired.gy) -------------------------------------------- import org.apache.commons.lang.StringUtils field1 = null for (i in formData) { if (field1 == null) { field1 = i.getValue(); } } isValid = false if (field1 != null) { field1 = StringUtils.trim(field1) if (field1 != "") { isValid = true } } result.setPassed(isValid) -------------------------------------------- Let me know what you think. Regards, Barrie Selack >I don't think I'll have time to implement that right now, but if you >implement that I'll be happy to apply it to CVS. Please make sure to >work off of the CVS head though. > >Sincerely, >Anthony Eden > >Barrie Selack wrote: >> I noticed that scripts are much slower than rules .. is there going to be >> any caching of scripts? Either configured to cache, or not cache... or >> cache with a date stamp? >> >> Let me know.. if not, I'll probably add it. >> >> Barrie >> >> >> >> >> ------------------------------------------------------- >> SF email is sponsored by - The IT Product Guide >> Read honest & candid reviews on hundreds of IT Products from real users. >> Discover which products truly live up to the hype. Start reading now. >> http://productguide.itmanagersjournal.com/ >> _______________________________________________ >> FormProc-developer mailing list >> For...@li... >> https://lists.sourceforge.net/lists/listinfo/formproc-developer > > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://productguide.itmanagersjournal.com/ >_______________________________________________ >FormProc-developer mailing list >For...@li... >https://lists.sourceforge.net/lists/listinfo/formproc-developer > > |