PDA

View Full Version : Form Message and Success View Newbe Question


sklakken
Apr 26th, 2005, 06:23 PM
I'm using a SimpleFormController to handle basic forms. After I hit the submit button, I'd like to do one of two things (not sure which one yet).

1. After I "Submit" I'd like to recall the udpate form and display an "Update Successful" message. The problem seems to be, however, is that all "responses" passed back to the form belong to the "command" class. So what I'd like to do is somehow add a message to the http response and pass it back to the calling JSP form.

Or.

2. Return to the "Success" view with data populated. I can currently redirect to that form, but the success view is not populated with any data. After going through the code with my debugger it appears that neither ModelAndView(...) nor formBackingObject(...) are called. So what I'm going to is an empty page. What I'd like is to call the ModelAndView equivilent and return to the form.

Either of these to methods would work for me, but I don't know how to implement either solution. Any help would be appreciated.

katentim
Apr 26th, 2005, 08:46 PM
After I "Submit" I'd like to recall the udpate form and display an "Update Successful" message
You can do something like this:
Controller
Map model = new HashMap();
model.put("saveSuccessful", new Boolean(true));
return showForm(request, response, errors, model);

JSP
<c:if test="${saveSuccessful}"><fmt:message key="saveSuccessful"/></c:if>

messages.properties
saveSuccessful=Save/Update was successful

sbmahs
Apr 29th, 2005, 05:14 AM
Hi,

I don't see a method call

showForm(request, response, errors, [b]model[/b]);

but I put the parameter on the request object as such:


request.setAttribute("myValue", value);
return showForm(request, response, errors);


Regards,
Stefan

katentim
Apr 29th, 2005, 07:09 AM
I don't see a method call...showForm(request, response, errors, model);
It's in the API here...showForm(request, response, errors, model) (http://www.springframework.org/docs/api/org/springframework/web/servlet/mvc/SimpleFormController.html#showForm(javax.servlet.h ttp.HttpServletRequest,%20javax.servlet.http.HttpS ervletResponse,%20org.springframework.validation.B indException,%20java.util.Map))