if (NumberTools.toBool(req.getParameter("AKTERA_auto"), false))
{
CommandInfo cmdInfo = (CommandInfo) (cmdPage != null && cmdPage.getModel() != null ? cmdPage.clone()
: cmdEdit.clone());
Command cmd = cmdInfo.createCommand(req, res, context);
for (Iterator i = req.getParameters().keySet().iterator(); i.hasNext();)
{
String key = (String) i.next();
if (! "model".equals(key) && ! "SEQUENCE_NAME".equals(key) && ! "SEQUENCE_NUMBER".equals(key))
{
cmd.setParameter(key, req.getParameters().get(key));
}
}
cmd.setParameter(keyName, id);
cmd.setParameter("reedit", "Y");
if (req.getParameter("ajax") != null)
{
cmd.setParameter("ajax", "Y");
}
return cmd.execute(req, res);
}
handler.preStorePersistents(req, formular, formular.getPersistents(), new Boolean(modified));
if (req.getParameter(NO_FORM_STORE) == null && validate
&& ! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
{
ValidationResult result = null;
try
{
result = FormTools.validateInput(req, res, formular, formular.getPersistents());
handler.validatePersistents(persistentConfig, req, res, formular, formular.getPersistents(),
NumberTools.toInt(id, - 1) == - 1, result);
}
catch (Exception x)
{
System.out.println("[Save] Error while validating input: " + x);
x.printStackTrace();
}
if (result.hasErrors())
{
formular.setPage(Math.max(formular.getPageWithField(result.getFirstErrorField(formular).replaceAll(
"_", ".")), 0));
}
result.createResponseElements(res, formular);
if (result.hasErrors())
{
CommandInfo cmdInfo = (CommandInfo) cmdEdit.clone();
Command cmd = cmdInfo.createCommand(req, res, context);
cmd.setParameter(keyName, id);
cmd.setParameter("error", result.getFirstErrorField(formular));
if (! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
{
return cmd.execute(req, res);
}
else
{
return res;
}
}
}
if (NumberTools.toInt(id, - 1) != - 1)
{
handler.updatePersistents(req, formular, formular.getPersistents(), persistentConfig, modified);
if (! preserveContext)
{
UserTools.removeContextObject(req, persistentsId);
}
}
else
{
id = new Integer(handler.createPersistents(req, formular, formular.getPersistents(), persistentConfig));
if (NumberTools.toInt(id, - 1) != - 1)
{
if (! preserveContext)
{
UserTools.removeContextObject(req, FormTools.createContextKey(contextId, - 1));
}
else
{
UserTools.setContextObject(req, FormTools.createContextKey(contextId, id), formular);
}
}
}
if (! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
{
context.setSaveId(id);
CommandInfo cmdInfo = (CommandInfo) cmdOk.clone();
Command cmd = cmdInfo.createCommand(req, res, context);
ModelRequest newReq = (ModelRequest) req.getService(ModelRequest.ROLE);
ModelResponse cmdRes = cmd.execute(newReq, res);
if (res.get("IRITGO_formMessages") != null)
{
cmdRes.add(res.get("IRITGO_formMessages"));
}