• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts validation framework- for single form, multiple actions

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have three struts actions and a single form bean. I am declaring three different form-beans in the struts-config.xml with three different form names for the same form bean java class. How can I validate the forms using the struts validator framework?

My struts-config.xml will look like this:

#########################################################################
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="customerRegistrationForm"
type="com.sag.form.CustomerRegistrationForm">
<form-property name="customerId" type="java.lang.String" />
<form-property name="customerName" type="java.lang.String" />
<form-property name="customerAddress"
type="java.lang.String" />
<form-property name="customerParentId"
type="java.lang.String" />
<form-property name="countryId" type="java.lang.String" />
<form-property name="clientDivision"
type="java.lang.String" />
</form-bean>
<form-bean name="projectRegistrationForm"
type="com.sag.form.CustomerRegistrationForm">
<form-property name="projectName" type="java.lang.String" />
<form-property name="projectType" type="java.lang.String" />
<form-property name="technology" type="java.lang.String" />
<form-property name="sbu" type="java.lang.String" />
<form-property name="projectProfiles"
type="java.lang.String" />
<form-property name="onsiteOffshore"
type="java.lang.String" />
<form-property name="noOfResources" type="java.lang.String" />
</form-bean>
<form-bean name="proposalRegistrationForm"
type="com.sag.form.CustomerRegistrationForm">
<form-property name="proposalSerialNumber"
type="java.lang.String" />
<form-property name="proposalNumber"
type="java.lang.String" />
<form-property name="quarter" type="java.lang.String" />
<form-property name="month" type="java.lang.String" />
<form-property name="salesContact" type="java.lang.String" />
<form-property name="sagContact" type="java.lang.String" />
<form-property name="deliveryContact"
type="java.lang.String" />
<form-property name="proposalValue" type="java.lang.String" />
<form-property name="currencyCode" type="java.lang.String" />
<form-property name="USDinMillion" type="java.lang.String" />
<form-property name="proposalSummary"
type="java.lang.String" />
<form-property name="customerWinQuarter"
type="java.lang.String" />
<form-property name="clientRegion" type="java.lang.String" />
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="getName" path="/pages/registration.jsp" />
</global-forwards>
<action-mappings>
<action input="/pages/registration.jsp"
name="customerRegistrationForm" path="/registerCustomer"
scope="session" type="com.sag.action.CustomerRegisterAction"
validate="true">
<forward name="success" path="/pages/registration.jsp" />
<forward name="failure" path="/pages/customer.jsp" />
</action>
<action input="/pages/registration.jsp"
name="projectRegistrationForm" path="/registerProject"
scope="session" type="com.sag.action.ProjectRegistrationAction"
validate="true">
<forward name="success" path="/pages/registration.jsp" />
<forward name="failure" path="/pages/customer.jsp" />
</action>
<action input="/pages/registration.jsp"
name="proposalRegistrationForm" path="/registerProposal"
scope="session" type="com.sag.action.ProposalRegistrationAction"
validate="true">
<forward name="success" path="/pages/registration.jsp" />
<forward name="failure" path="/pages/customer.jsp" />
</action>
<action input="/pages/registration.jsp"
name="customerRegistrationForm" path="/register" scope="session"
type="com.sag.action.CustomerRegisterAction">
<forward name="success" path="/pages/registration.jsp" />
<forward name="failure" path="/pages/customer.jsp" />
</action>
</action-mappings>
<controller />
<message-resources parameter="ApplicationResources" />
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>
##########################################################################


Inside my jsp for the form, I am declaring the script for enabling the client side alert as:


#####################################################################
<html:javascript formName="customerRegistrationForm"
method="validateForm" dynamicJavascript="true" staticJavascript="false"
cdata="false" />
<html:javascript formName="projectRegistrationForm"
method="validateForm" dynamicJavascript="true" staticJavascript="false"
cdata="false" />
<html:javascript formName="proposalRegistrationForm"
method="validateForm" dynamicJavascript="true" staticJavascript="false"
cdata="false" />

##########################################################
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to our Struts forum.

Mark
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Palayoor

i think that this
link
is the solution
read carefully all the document

regards
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic