Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Struts
Struts 2 validation using Annotation is not working
Arun Giridharan
Ranch Hand
Posts: 290
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm doing validation for Name,but it seems there some problem (it's not working)
login.jsp
<s:actionerror /> <s:form action="AddAction" method="POST" > <s:textfield name="modelName" key="add.modelName"> </s:textfield> </s:form>
My Value Object has
public class ModelVO { private String modelName; @RequiredStringValidator(fieldName="modelName",type=ValidatorType.FIELD,trim=true,shortCircuit=true,message="addCarModel.validate.notnull.modelName") /*@StringLengthFieldValidator(fieldName="modelName",type=ValidatorType.FIELD,minLength="3",maxLength="50",shortCircuit=true,message="")*/ public String getModelName() { return modelName; } public void setModelName(String modelName) { this.modelName = modelName; } }
struts.xml (piece of my struts.xml)
<action name="AddNameAction" method="addName" class="com.home.web.action.AddNameAction"> <result name="input">login.jsp</result> <result name="success" type="redirect">DisplayAll.action</result> </action>
public class AddNameAction extends ActionSupport implements ModelDriven { private ModelVO modelVO = new ModelVO(); public Object getModel() { return modelVO; } ....................... ................. }
I really don't know what is the reason,why it's not validating
Thank You
kolipakula babu
Greenhorn
Posts: 1
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi ,
In the Form you have to add Validation= "true" like below. Try this it will work.
<s:form action="AnnotationAction" method="POST" validate="true">
Regards,
Surendra
Arun Giridharan
Ranch Hand
Posts: 290
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i forgot to see , the Model validation :P
@VisitorFieldValidator(appendPrefix = false, message = "it's required", shortCircuit = false, fieldName = "model")
Arun Giridharan
Ranch Hand
Posts: 290
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
So,how to validate a long value ?? ,i can't use
@IntRangeFieldValidator(fieldName="noOfSmallSuitcases",type=ValidatorType.FIELD,min="0",max="25",shortCircuit=false,key="addCarModel.validate.noOfSmallSuitcases")
which give an TypeConversion error, so what can i do,i'm not getting it,how can i solve the issue.
Arun Giridharan
Ranch Hand
Posts: 290
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use Double , it's working fine!
I'm still in control here. LOOK at this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Struts2 validation using annotaions for Model Driven
After validate ajax form not redirect to success or error result
Vallidation Using Annotation + Struts 2
problem in struts validation
separate validation for each method in action class
More...