From: Keats K. <ke...@ea...> - 2005-07-10 03:20:38
|
There are many ways to handle this situation, but throwing an exception is not one I would recommend. Typically the Servlet just puts some error info into the context and then the template checks for the error info and displays a message to the user, e.g., // handler code in Servlet ... if (!valid(request)) { context.put("ErrorMsg", getLocalizedMsg(INVALID_DATA)); // reload form with error message template = formTemplate; } else { // display verification page to user template = verifyTemplate; } ... ## template ... <form ... #if ($ErrorMsg) { <p class="ErrorText">$ErrorMsg</p> } ... #if ($Form.someName){ #set $val = $HTMLEscape($Form.someName) } #else { #set $val = "" } <input name="someName" type="TEXT" value="$val" /> ... </form> ... Hope this helps. Keats ----- Original Message ----- From: "Dominik" <do...@db...> To: <web...@li...> Sent: Saturday, July 09, 2005 7:29 PM Subject: [WebMacro-user] Messages with Webmacro > Hy, > I'm using Webmacro to develop a small Webapp. No I ran into problems > because > I need a function to call, if I want to post a Message. > For example, take a guestbook-webapp: When you submit the entry-form the > app > checks whether all entered data is ok, when it is ok, then a page with the > data is displayed (via a template). But, when the data is not wellformed > then there should be a message telling the user to go back and refill the > page. As a solution I found out that I could throw a HandlerException, but > I > want the message to be shown in my own layout. The Handler-Exception also > produces another Problem: > On every Page-Request the app gets a database-connection from a > connection-pool and puts it back on the very and of each handler-call. > But, > when I throw a Handler-Exception the end of the handler-call is never > reached so the connection isn't put back into the pool. > > Is there a solution? > > Thanks > Dominik > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the 'Do More With Dual!' webinar > happening > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > core and dual graphics technology at this free one hour event hosted by > HP, > AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > _______________________________________________ > Webmacro-user mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-user > |