Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

validate to check errors on jsp

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not initializing my page from jsp but from .do action.
I get a form.
I have a jsp-Action class-form defined in struts, and properties for I11N in application.properties file.

I want to check the prompt user with error when any of the fields are null or empty.

So I added validate() in my ~Form class. in struts i added the validate="true".
I added <html:errors bundle="MyResources"/> before form tag.
When i click submit(i.e. save operation), i am not coming back to the form. what may be the reason?


public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();

boolean mappingSetNameEntered=false;
System.out.println("in validate operation="+ _operation);
if(_operation=="save") {
if(mappingSetName ==null || mappingSetName.length()<1) {
errors.add("mappingSetName", new ActionError("error.mappingSetName.required"));
System.out.println("Inside validate:"+ mappingSetName);
}
}

return errors;
}

please help.
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
btw,
error.mappingSetName.required=mappingsetname cannot be null

is in my application.properties file
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the following in your struts-config.xml action definition.

input="/nameOfJspForm.jsp"
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
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!