updating edit request dispatch controller to utilize edit configuration generator from session if it exists

This commit is contained in:
hudajkhan 2012-12-03 17:10:25 -05:00
parent 1d880ea29d
commit 4c4334d6f4

View file

@ -155,12 +155,25 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
private EditConfigurationVTwo setupEditConfiguration(String editConfGeneratorName, private EditConfigurationVTwo setupEditConfiguration(String editConfGeneratorName,
VitroRequest vreq) throws Exception { VitroRequest vreq) throws Exception {
HttpSession session = vreq.getSession(); HttpSession session = vreq.getSession();
EditConfigurationVTwo editConfig = //Originally, this code called makeEditConfiguration before checking for/setting the edit key
makeEditConfigurationVTwo( editConfGeneratorName, vreq, session); //which meant that in the case of page reload on an error, you would recreate an edit configuration
//using the generator
//edit key is set here, NOT in the generator class //Given recent updates enabling modification of edit configuration dynamically through AJAX,
String editKey = EditConfigurationUtils.getEditKey(vreq); //we will first check whether the edit key exists and if there is already an edit configuration
editConfig.setEditKey(editKey); //in the session - and then will utilize the edit configuration that already exists
//edit key is set here, NOT in the generator class
EditConfigurationVTwo editConfig = null;
EditConfigurationVTwo existingConfig = EditConfigurationVTwo.getConfigFromSession(session, vreq);
if(existingConfig != null) {
editConfig = existingConfig;
} else {
editConfig =
makeEditConfigurationVTwo( editConfGeneratorName, vreq, session);
}
String editKey = EditConfigurationUtils.getEditKey(vreq);
editConfig.setEditKey(editKey);
//put edit configuration in session so it can be accessed on form submit. //put edit configuration in session so it can be accessed on form submit.
EditConfigurationVTwo.putConfigInSession(editConfig, session); EditConfigurationVTwo.putConfigInSession(editConfig, session);