Win a copy of Head First Android this week in the Android 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

about the validation

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, I have some questions about the validation process.

I have this form to register a user, and it uses the the client-side validation framework and aldo the validate method of the form form server-side.

My question is, once the form validates that all fields are well formated, where do I do a validation for check if the username is already chosen, in the form or in the action?

if in the form: doesn't this breaks the mvc pattern? the form will know how the logic works

if in the action: how can I report the "login already in use" to the same page that has the form?

thanks
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Action class.

Add error message in Action class like this


And write your error page name in <action ----- input="errorPageName">

HTH
V
[ May 13, 2008: Message edited by: Vishal Matere ]
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply.

but that way you showed it redirects to another page.

I would like to know if its possible to show the error in the the same page, like errors that says that a field is required and are show in <html:errors>

thanks
 
Vishal Matere
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
simple.
use same page in your input attribute...
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm tryng that. But it doesnt show the error in the page. I do some println to see if the error is added and it prints ok.

but doesn't show the error in the <html:errors/>
 
Vishal Matere
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is this error message externalised?

In struts-config.xml file


in ApplicationResources.properties file


HTH
V
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks dude, It's working now.

ActionMessages errors = new ActionMessages();
errors.add("userid",new ActionMessage("errors.user.already.exists"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
 
Vishal Matere
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good to know it worked...

V
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

return new ActionForward(mapping.getInput());



You better use this 'return mapping.getInputForward();'
 
reply
    Bookmark Topic Watch Topic
  • New Topic