• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

validation part is not working in my stuts.

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

How do you do? i am fine. i hope that you are all fine.

I have some doubt about struts.

1. I created Bean name IlmLowBatExceptionBean.java and made entry into struts.config.xml like
<form-bean name="ilmlowbatException" type="com.atroad.exception.bean.IlmLowBatExceptionBean"/>


2.I created validation stuff into validation.xml like

<form name="ilmlowbatException">
<field property="exceptionName" page="1" depends="required, mask">
<arg0 key="ilmlowbatException.exceptionName"/>
<msg name="mask" key="error.exceptionName.mask"/>
<var>
<var-name>mask</var-name>
<var-value>${name}</var-value>
</var>
</field>
</form>

3.I entered appropriate message into properties file for the field that i have specified above.Its look like

error.exceptionName = Exception Name

i have created everthing like action,jsp .It is working fine,but validation part only cannot work.

Note: i included validation.jar file also.

could anyone please suggest me?

Is there any alternative way to proceed validation part .

Thanks
Arulraj
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arul,

For Struts validation you need to do the following things.

1. Create a Form by extending ValidatorForm.
2. Should have validation-rules.xml and validation.xml files in WEB-INF folder.
3. JSP which uses the form.
4. An action mapping entry with attribute validate=true, in struts-config file.
5. A plug in for validation file in struts-config file.

Check the above things it might help you.

Srilakshmi
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should explicitly specify the validate="true" in struts-config.xml file. Other wise, it takes default value which might be "false". Try it and let me know if it works.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Subha Rangu:
You should explicitly specify the validate="true" in struts-config.xml file. Other wise, it takes default value which might be "false". Try it and let me know if it works.


I think the default is validate="true".
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for action mapping, default 'validate' attribute, if not specified is 'false'. mark, i think you may be thinking about the default 'scope' attribute, which if not specified is defaulted to 'session'.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another thing to check is the validation-rules.xml and the version of struts. if you're using struts 1.2.x, you should NOT have any ActionErrors in your validation-rules.xml definitions.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right. I never rely on the defaults and now you know why - I can never remember which is what!
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same here mark...i always try to be as explicit as possible, but still fall into the default pit every so often simply because there are so many attributes (and many that are alike) for the various tags.
 
This tiny ad is wafer thin:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!