I have some jsp page manage.jsp and form inside it:
<form method="POST" action="./manage.form">
<div style=" float: left;">
<textarea id="errors" name="errors">${ignoredExceptions}</textarea>
</div>
<div id="successOrErrorSave"></div>
<div style="clear: both;">
<input type="submit" id="saveIgnoredErrors" style="margin-left: auto; margin-top: 10px;" value="<spring:message code="errorlogging.ignredExceptions.save" />"/>
</div>
</form>
And I have some controller ManageController:
/**
* The main controller.
*/
@Controller
public class ManageController {
protected final Log log = LogFactory.getLog(getClass());
@RequestMapping(value = "/module/manage", method = RequestMethod.GET)
public void showForm(ModelMap model) {
GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject(
Constants.GP_IGNORED_EXCEPTION);
if (glProp != null) {
model.addAttribute("ignoredExceptions", glProp.getPropertyValue());
} else {
model.addAttribute("ignoredExceptions", "");
}
}
@RequestMapping(value = "module/manage", method = RequestMethod.POST)
public String processSubmit(@ModelAttribute(value = "ignoredExceptions") String ignoredExceprions, BindingResult result,
SessionStatus status) {
boolean successSave = false;
GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject(
ErrorLoggingConstants.ERRROR_LOGGING_GP_IGNORED_EXCEPTION);
if (glProp != null) {
glProp.setPropertyValue(ignoredExceprions);
GlobalProperty saved = Context.getAdministrationService().saveGlobalProperty(glProp);
System.out.println(saved.getPropertyValue());
if (saved != null && saved.getPropertyValue().equals(ignoredExceprions)) {
successSave = true;
}
}
status.setComplete();
return "module/manage";
}
}
When I open manage page in the textarea I’m showing current ignoredExceptions. I need to save new value of ignoredExceptions, which user entered and after than redirect to the same manage page, which will view new value of ignoredExceptions. How can I do this?
The changed value of ignoredExceptions is tied to the textarea field named errors in the form so you could read the value of errors from the request or as RequestParameter
}