• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bear's FrontMan, how to do general error messages

 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using FrontMan, and like it a lot. (Thanks Bear). But I can't figure out how to handle error messages.

For example, I have a login.jsp that gathers user and password from a form. It is backed by a Login.class with @FrontmanCommand("login")

When I get the form's data, I look up the user, compare the hashed passwords and either let them in or give them an error message and go back to the login form.

I can't get the error messages to display. I have a code snippet such as


in the JSP, but each time its executed, the error message list is zero. No entries. I don't know if the JSP page is loading a new instance of the bean, if I'm doing it all wrong, etc.

Please any help greatly appreciated.
Thanks
Pat
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As simply a front controller implementation, Front Man doesn't have any error handling built in so that you can use whatever works best for your app.

For example, in the Web 2.0 (I hate that term!) application that I'm currently working on, almost all form submissions happen through Ajax, and errors are returned as a JSON serialization that is then integrated with the jQuery Validation plugin for display.

Obviously that's not appropriate for all apps.

For a canonical Model-2 web app, I used to tack a "message list" object onto the session (used the PRG pattern, so can't simply carry it on the request) for display on the page in the event of error. The list would be removed form the session upon display.

So, the best way for your app to carry error messages to the view depends upon how it's structured. Does your login command forward back to the form on error? If so, carrying the message(s) on the request should work fine. If a redirect, the session might work better (with appropriate cleanup code). Under Ajax, a JSON response works great. And so on...
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No AJAX here, yet.
Just a form that POSTs to the command (login) which can either succeed or fail.
Same form on failure, just with "login failed" error message.

So you are suggesting a session variable accessible with EL for the error list?

I'm not having any luck tying the jsp page to the bean object and keeping the error list there. Its getting cleared each time the page is drawn.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the error, how are you transitioning back to the login form page?
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:After the error, how are you transitioning back to the login form page?




So it goes back to the login jsp page if there are errors, such as bad password
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case a scoped variable on the request could be used as you are forwarding the same request to the view:


The list would be available on the page as ${messageList}.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try that. Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic