Results 1 to 2 of 2
Thread: error message on jsp
- 04-11-2007, 02:53 AM #1
Member
- Join Date
- Apr 2007
- Location
- Pennsylvania,USA
- Posts
- 45
- Rep Power
- 0
error message on jsp
Am trying to learn struts...not easy.
Anyway, I want to display an error message on a page if the user forgets to enter a field. I figured out how to do that with the validate() method in the ActionForm. OK, but now I want to make the error show up if they did something the database does not like. So I am off into the Action now.
Lets say they want to order some widgets, and there were some in the inventory when the screen came up, but they looked at it a while, they went and had a cup of coffee, and when they got back and clicked the "order" button the application goes out to the database and lo and behold, there are no more widgets left. So how do I deal with this and show that nice little error message on the same screen. "sorry, the last widget has been sold".
- 04-11-2007, 03:10 AM #2
Member
- Join Date
- Apr 2007
- Location
- Indiana
- Posts
- 83
- Rep Power
- 0
Here is how I normally handle something like this:
Java Code:public ActionForward getWidgets(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionForward forward = new ActionForward(); try { List widgets=WidgetManager.getWidgets(); forward = mapping.findForward("gotthem"); } catch (NoWidgetsFoundException e) { errors.add("noWidgetsLeftError", new ActionMessage("error.noWidgetsLeftError")); saveErrors(request, errors); } return (forward); }
Similar Threads
-
Please wail Message in jsp
By amar.java in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-02-2008, 01:29 PM -
java error message
By baileyr in forum New To JavaReplies: 2Last Post: 01-23-2008, 04:47 AM -
Strange error message "Source not found"
By ppayal in forum EclipseReplies: 0Last Post: 11-25-2007, 07:19 PM -
Help with error message when running JAR via HTML file
By Simmy in forum AWT / SwingReplies: 7Last Post: 08-12-2007, 04:47 PM -
About bean:message
By yuchuang in forum Web FrameworksReplies: 1Last Post: 05-03-2007, 05:50 PM
Bookmarks