aspose file tools*
The moose likes Other Open Source Projects and the fly likes Bear's FrontMan, how to do general error messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Bear Watch "Bear New topic
Author

Bear's FrontMan, how to do general error messages

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

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

Joined: Jan 10, 2002
Posts: 61221
    
  66

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...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

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

Joined: Jan 10, 2002
Posts: 61221
    
  66

After the error, how are you transitioning back to the login form page?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

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

Joined: Jan 10, 2002
Posts: 61221
    
  66

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

Joined: Aug 11, 2007
Posts: 4658
    
    5

I'll try that. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bear's FrontMan, how to do general error messages