| Author |
Struts Validation in Spring Context
|
Saman Perera
Ranch Hand
Joined: Jul 15, 2003
Posts: 61
|
|
Hi all Pls tell me any one how to use struts validation framework in the spring context , i did samething which i did in the struts web project , validation frame work with LookupDispatchAction and DynaValidatorForm , it is not work properly , pls tell me how to do this Thanks Saman ERROR --------------------- There is a error callled Messages are not found i put all the keys correctly following are some of resources Struts Config ---------------- <!-- Form Bean --> <form-bean name="createSellRateForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="customer" type="java.lang.String" /> <form-property name="accountNo" type="java.lang.String" /> <form-property name="logisticService" type="java.lang.String" /> <form-property name="transportService" type="java.lang.String" /> <form-property name="buyRateCard" type="java.lang.String" /> <form-property name="sellRateCard" type="java.lang.String" /> <form-property name="currency" type="java.lang.String" /> <form-property name="dispatch" type="java.lang.String" /> <form-property name="adjustmentCriteria" type="java.lang.String" initial="P" /> <form-property name="adjustment" type="java.lang.String" initial="I" /> <form-property name="adjustmentAmount" type="java.lang.Double" initial="0.0" /> </form-bean> <!-- properties --> <message-resources key="settlements" parameter="com.parcelhouse.settlements.web.messages" null="false"/> <!-- plugins --> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validator.xml" /> <set-property property="stopOnFirstError" value="true" /> </plug-in> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/settlements-tiles-defs.xml"/> </plug-in> part of web XML --------------- <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>com.parcelhouse.settlements.web.messages</param-value> </context-param> validator.xml ----------------------- <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd"> <form-validation> <formset> <form name="createSellRateForm"> <field property="adjustmentAmount" depends="required,integer"> <arg0 key="createSellRate.adjustmentAmount"/> </field> </form> </formset> </form-validation> JSP --------------- <logic:messagesPresent message="false"> <div class="error"> Errors <ul> <html:messages id="error" message="false"> <li><c ut value="${error}"/></li> </html:messages> </ul> </div> </logic:messagesPresent> Application context --------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for settlements on Hibernate. --> <beans> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <!-- Configurer that replaces ${...} placeholders with values from a properties file --> <!-- (in this case, JDBC-related settings for the dataSource definition below) --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/jdbc.properties"/> </bean> <!-- Local DataSource that works in any environment --> <!-- Note that DriverManagerDataSource does not pool; it is not intended for production --> <!-- See JPetStore for an example of using Commons DBCP BasicDataSource as alternative --> <!-- See Image Database for an example of using C3P0 ComboPooledDataSource as alternative --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!-- JNDI DataSource for J2EE environments --> <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/petclinic"/> </bean> --> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <value>com/parcelhouse/settlements/entity/hbm/mappings/all.hbm.xml</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.generate_statistics">true</prop> <!-- <prop key="hibernate.hbm2ddl.auto">create</prop> --> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <property name="eventListeners"> <map> <entry key="merge"> <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/> </entry> </map> </property> </bean> <bean id="methodInvokingJobDetail" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"> <property name="targetObject"><ref bean="folderListener"/></property> <property name="targetMethod"><value>init</value></property> </bean> <bean id="folderListener" class="com.parcelhouse.settlements.listener.FolderListener"/> <bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask"> <property name="delay"> <value>10000</value> </property> <property name="period"> <value>-1</value> </property> <property name="timerTask"> <ref local="methodInvokingJobDetail"/> </property> </bean> <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean"> <property name="scheduledTimerTasks"> <list> <ref local="scheduledTask"/> </list> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) --> <!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> --> <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --> <bean id="persistenceService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"/> <property name="target" ref="poolPersistenceManagerHandler"/> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="store*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="poolPersistenceManagerHandler" class="org.springframework.aop.target.CommonsPoolTargetSource"> <property name="targetBeanName"> <value>persistenceManagerImpl</value> </property> <property name="maxSize"> <value>15</value> </property> </bean> <bean id="businessService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"/> <property name="target" ref="poolBusinessServiceHandler"/> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="store*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="poolBusinessServiceHandler" class="org.springframework.aop.target.CommonsPoolTargetSource"> <property name="targetBeanName"> <value>businessServiceManagerImpl</value> </property> <property name="maxSize"> <value>15</value> </property> </bean> <!-- ################### BusinessServiceManager (end) ##################### --> <!-- Hibernate 3.0's JMX statistics service --> <!-- Implements the StatisticsServiceMBean management interface --> <bean name="petclinic:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- ========================= JMX EXPORTER DEFINITION ========================= --> <!-- - Exporter that exposes Hibernate 3.0's statistics service via JMX. - Autodetects the statistics service, which is a standard MBean, - using its bean name as JMX object name. - - By default, the standard MBeanServerFactory.findMBeanServer method will be used - to determine the MBeanServer. Unfortunately, this does not work on WebLogic <= 8.1: - you need to comment in the WebLogicMBeanServerFactoryBean definition on WebLogic, - specifying appropriate configuration values there. --> <bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter"> <property name="autodetect" value="true"/> <!-- Comment the following in on WebLogic <= 8.1, which doesn't support --> <!-- the standard MBeanServerFactory.findMBeanServer lookup mechanism. --> <!-- <property name="server"> <bean class="org.springframework.jmx.support.WebLogicJndiMBeanServerFactoryBean"/> </property> --> </bean> </beans>
|
 |
 |
|
|
subject: Struts Validation in Spring Context
|
|
|