• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to reuse action class with xml validation

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
Iam using validation.xml for validation.The problem here is if i have a Action class and its corresponding form (which has an entry in validation.xml)

Eg:
-------------------------------------------------------------------------
/*@struts.action path = "/editCustomer" name = "editForm" scope = "request" validate="true" input="ErrorEdit"
*
* * @struts.action-forward name = "ErrorEdit" path="editShopperTile"
*
*/
public class EditShopperAction extends AbstractAction{
public void execute(StrutsActionContext actionContext) {
---------------------------------------------------------------------------
Form Bean

/**
* @struts.form name="editForm"
*/
public class EditForm extends ValidatorForm {
private String etelephone;
/**
* @struts.validator type="required" msgkey="CustomerForm.telephone"
**/
public void setEtelephone(String etelephone) {
this.etelephone = etelephone;
}
---------------------------------------------------------------------------

Problem
-------
When my action class gets loaded it checks fro validate =true and validation is performed before entering values.Here for eg telephone ..while the form is loaded telephone =null and hence it showing me the validation failure result.

How to skip validation in this case.

Im using two action class for this.One for displaying the filling form and other to check validation.

Can anyone give me a solution to this

Thanks in advance

Venkatesh Loganathan
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

see u can do this ..........in one action say validate=true and in another action say validate=false .so in the later case the validation rules will be skipped even though u r using the same form bean in both the cases
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wont work. i have tried it out.
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the exact same problem. I have a form bean but i am calling two action classes basically because i have 4 drop downs and for each i have to go to the database an dcome back. When the request happens all what i typed in my form is gone and the drop downs dont retain their values. Any idea on how this can be done?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sreenath said does work. Your situation might be a tad different, charu. It might be worth it to start a new thread and explain your problem in a little more detail.
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI vankatesh

Sorry to tell u that ....strust 1.1 provides a better way for what u asked ......even though what i said will also work but will tell u ....there is validatoractionform in struts...........for this actually the rules from xml will be picked based on the path attribute from the struts-config.xml rather than the form name attribute..............this is teh purpose of introducing this where two actions can share the same form bean with different sets of validatiions


hope this will help u in better way than what i said earluer
 
I found some pretty shells, some sea glass and this lovely tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic