Re: Validator and business rule
Hello Guys, Anyone can talk about my message? It's a good idea or I'm crazy? []'s, Regis - Original Message - From: Regis Melo [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Sunday, February 02, 2003 11:57 AM Subject: Re: Validator and business rule Hello David, I think that the main problem in struts-validator is because is highly coupled with ActionForm. Ok, I can use commons-validator. But, my idea is: * Put the validation rules in only one place (a XML file that can be read and interpretated by struts and my business rule); * The validation rule also has the type of a column (indicating if is boolean, data, String, BigDecimal, ... ); * The struts tags will generate JavaScript to validate the input of data; * My business rule will check if all data is ok again (because the user can turn off JavaScript). My business rule generaly receives a Value Object to insert or update data. My VO is dynamic - I say which columns and rows they will have. If I know the type of data that came from ActionForm (I always use String in ActionForms) I can convert on fly the data between ActionForm and VO. Theres is a sample example: - Action -- MyValueObject vo = new MyValueObject( form );// Works because I will know the types of columns in ActionForm - it's defined in XML MyBusinessObject bo = new MyBusinessObject(); bo.insert( vo ); - MyBusinessObject - public void insert( MyValueObject vo ) { if not checkIfAlwaysIsOk( vo ) { throw new Exception( ... ); } insertIntoDatabase( ); // If a need to get some data from VO, I use - vo.get( lineNumber, columnNumber ) } public boolean checkIfAlwaysIsOk( vo ) { return Validator.checkIfRulesIsOk( vo, file with xml definitions ); // Validator is a generic class that will be used by struts-validator and my business rule } Thanks, Regis Melo - Original Message - From: David Graham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 01, 2003 7:03 PM Subject: Re: Validator and business rule You can use the generic commons-validator in your business logic if you want. The Struts version and the commons version can use the same xml config file for the validation rules. David From: Regis Melo [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Validator and business rule Date: Sat, 1 Feb 2003 18:23:00 -0300 Hello, Why Struts-validator is so highly coupled with ActionForms? I think that is a good idea to use struts-validator to do some work in my business classes. How can I do that? Thanks, Regis Melo _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to use DBCP with Struts
Hello, I'm trying to use the DBCP with Struts. My struts-config.xml is: data-source key=sgr type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=com.microsoft.jdbc.sqlserver.SQLServerDriver / set-property property=url value=jdbc:microsoft:sqlserver://JAVA:1433;DatabaseName=SGR;selectmethod=cursor / set-property property=maxActive value=2 / !-- Cresce de forma indefinida -- set-property property=maxIdle value=5 / !-- Terá pelo menos 5 conexões no pool -- set-property property=maxWait value=-1 / !-- O cliente esperará indefinidamente pelo pool -- set-property property=validationQuery value=select 'SoftSite TBCW' / set-property property=removeAbandoned value=true / set-property property=defaultAutoCommit value=false / set-property property=defaultReadOnly value=false / set-property property=userName value=sa / set-property property=password value=secret / /data-source But, I always receive the follow error (in tomcat logs): java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:386) at org.apache.commons.dbcp.BasicDataSource.createDataSource(Unknown Source) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(Unknown Source) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServlet.java:846) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:419) at javax.servlet.GenericServlet.init(GenericServlet.java:258) What can I do? T.I.A., Regis Melo
Re: How to use DBCP with Struts
Hello David! How can I do that? I'm using DataSource dataSource = servlet.findDataSource( poolName ) to obtain a datasource from connection pool. I only need to set the removeAbandoned to true. There is any way to do this using struts? Regis Melo - Original Message - From: David Graham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 12:33 PM Subject: Re: How to use DBCP with Struts First, make sure you can create a BasicDataSource instance on your db without using Struts. Then, configure the properties in struts-config.xml. David From: Regis Melo [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: How to use DBCP with Struts Date: Mon, 3 Feb 2003 12:14:03 -0300 Hello, I'm trying to use the DBCP with Struts. My struts-config.xml is: data-source key=sgr type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=com.microsoft.jdbc.sqlserver.SQLServerDriver / set-property property=url value=jdbc:microsoft:sqlserver://JAVA:1433;DatabaseName=SGR;selectmethod=c ursor / set-property property=maxActive value=2 / !-- Cresce de forma indefinida -- set-property property=maxIdle value=5 / !-- Terá pelo menos 5 conexões no pool -- set-property property=maxWait value=-1 / !-- O cliente esperará indefinidamente pelo pool -- set-property property=validationQuery value=select 'SoftSite TBCW' / set-property property=removeAbandoned value=true / set-property property=defaultAutoCommit value=false / set-property property=defaultReadOnly value=false / set-property property=userName value=sa / set-property property=password value=secret / /data-source But, I always receive the follow error (in tomcat logs): java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:386) at org.apache.commons.dbcp.BasicDataSource.createDataSource(Unknown Source) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(Unknown Source) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionSer vlet.java:846) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:419) at javax.servlet.GenericServlet.init(GenericServlet.java:258) What can I do? T.I.A., Regis Melo _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use DBCP with Struts
David, I already do that. But, the error that appear is the same error that occurred in Struts I'm using Microsoft SQL JDBC Driver (2000). T.I.A., Regis Melo - Original Message - From: David Graham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 3:05 PM Subject: Re: How to use DBCP with Struts You create a BasicDataSource object the same way you create any other java object. See the BasicDataSource javadoc for details. Once you have successfully created the object for your database, then you can easily set it up in struts-config.xml. David From: Regis Melo [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: How to use DBCP with Struts Date: Mon, 3 Feb 2003 13:22:22 -0300 Hello David! How can I do that? I'm using DataSource dataSource = servlet.findDataSource( poolName ) to obtain a datasource from connection pool. I only need to set the removeAbandoned to true. There is any way to do this using struts? Regis Melo - Original Message - From: David Graham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 12:33 PM Subject: Re: How to use DBCP with Struts First, make sure you can create a BasicDataSource instance on your db without using Struts. Then, configure the properties in struts-config.xml. David From: Regis Melo [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: How to use DBCP with Struts Date: Mon, 3 Feb 2003 12:14:03 -0300 Hello, I'm trying to use the DBCP with Struts. My struts-config.xml is: data-source key=sgr type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=com.microsoft.jdbc.sqlserver.SQLServerDriver / set-property property=url value=jdbc:microsoft:sqlserver://JAVA:1433;DatabaseName=SGR;selectmethod=c ursor / set-property property=maxActive value=2 / !-- Cresce de forma indefinida -- set-property property=maxIdle value=5 / !-- Terá pelo menos 5 conexões no pool -- set-property property=maxWait value=-1 / !-- O cliente esperará indefinidamente pelo pool -- set-property property=validationQuery value=select 'SoftSite TBCW' / set-property property=removeAbandoned value=true / set-property property=defaultAutoCommit value=false / set-property property=defaultReadOnly value=false / set-property property=userName value=sa / set-property property=password value=secret / /data-source But, I always receive the follow error (in tomcat logs): java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:386) at org.apache.commons.dbcp.BasicDataSource.createDataSource(Unknown Source) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(Unknown Source) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionSer vlet.java:846) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:419) at javax.servlet.GenericServlet.init(GenericServlet.java:258) What can I do? T.I.A., Regis Melo _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator and business rule
Hello David, I think that the main problem in struts-validator is because is highly coupled with ActionForm. Ok, I can use commons-validator. But, my idea is: * Put the validation rules in only one place (a XML file that can be read and interpretated by struts and my business rule); * The validation rule also has the type of a column (indicating if is boolean, data, String, BigDecimal, ... ); * The struts tags will generate JavaScript to validate the input of data; * My business rule will check if all data is ok again (because the user can turn off JavaScript). My business rule generaly receives a Value Object to insert or update data. My VO is dynamic - I say which columns and rows they will have. If I know the type of data that came from ActionForm (I always use String in ActionForms) I can convert on fly the data between ActionForm and VO. Theres is a sample example: - Action -- MyValueObject vo = new MyValueObject( form );// Works because I will know the types of columns in ActionForm - it's defined in XML MyBusinessObject bo = new MyBusinessObject(); bo.insert( vo ); - MyBusinessObject - public void insert( MyValueObject vo ) { if not checkIfAlwaysIsOk( vo ) { throw new Exception( ... ); } insertIntoDatabase( ); // If a need to get some data from VO, I use - vo.get( lineNumber, columnNumber ) } public boolean checkIfAlwaysIsOk( vo ) { return Validator.checkIfRulesIsOk( vo, file with xml definitions ); // Validator is a generic class that will be used by struts-validator and my business rule } Thanks, Regis Melo - Original Message - From: David Graham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 01, 2003 7:03 PM Subject: Re: Validator and business rule You can use the generic commons-validator in your business logic if you want. The Struts version and the commons version can use the same xml config file for the validation rules. David From: Regis Melo [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Validator and business rule Date: Sat, 1 Feb 2003 18:23:00 -0300 Hello, Why Struts-validator is so highly coupled with ActionForms? I think that is a good idea to use struts-validator to do some work in my business classes. How can I do that? Thanks, Regis Melo _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] So much time, so little to do ...
Winston Churchill sad: 'Never in the history of human conflict has so much been owed by so many to so few.' Ok! I'm not the first But, I'm original! What do You think Ted? :-) ;-) - Original Message - From: Ted Husted [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, February 02, 2003 8:09 PM Subject: [OT] So much time, so little to do ... No, stop. Rewind and reverse that. =:0) Okay trivia geeks, who said Never has so much been owed by so many to so few lines of code and what so few lines of code are we talking about? Yet another autographed copy of Struts in Action to the first lucky emailer with the correct answers. (Prior winners excluded.) Hint: It wasn't Gene Wilder =:0) -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator and business rule
Hello, Why Struts-validator is so highly coupled with ActionForms? I think that is a good idea to use struts-validator to do some work in my business classes. How can I do that? Thanks, Regis Melo