1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (logger.isDebugEnabled()) {
logger.debug("perform : start");
}
/* check expired session */
ActionForward forward = super.execute(mapping, form, request, response);
ActionErrors errors = null;
if (forward != null) {
return forward;
}
//HttpSession session = request.getSession();
//ActionMessages messages = null;
/* get action */
SearchTemplatesForm searchTemplatesForm = (SearchTemplatesForm) form;
String action = searchTemplatesForm.getAction();
if (null == action) // Correction Bug IE qui ne soumet pas le nom de l'action quand on appuie sur la touche "Enter"
{
action ="Lancer la recherche";
}
if (logger.isDebugEnabled()) {
logger.debug("perform : action = " + action);
}
if ("Lancer la recherche".equals(action) == false) {
throw new ServletException("SearchTemplateAction.perform : bad action value " + action);
}
/* check input data with the validator */
errors = form.validate(mapping, request);
if (errors!= null) {
if (errors.size() != 0) {
saveMessages(request, (ActionMessages) errors);
return new ActionForward(mapping.getInput());
}
} else
errors = new ActionErrors();
/* search templates */
if (logger.isDebugEnabled()) {
logger.debug("perform : bouton recherche de templates selectionné");
}
/* get template code */
Integer code = null;
try {
code = new Integer(searchTemplatesForm.getCode().trim());
} catch (NumberFormatException e) { }
/* get status */
String type = searchTemplatesForm.getType();
if (true == SearchTemplatesForm.ALL_TYPE.equalsIgnoreCase(type))
type = null;
try {
Collection templates = DAOMsgTemplate.findTemplates(HibernateFilter.getSession(), code, type,MsgTemplate.V2_VERSION);
if (templates.isEmpty()) {
//
logger.info(30069, "Aucun template trouvé pour le code: " + code + ", type: " + type +", version" + MsgTemplate.V2_VERSION);
//session.removeAttribute("templatesCollection");
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("info.template.search"));
saveErrors(request, (ActionMessages) errors);
return new ActionForward(mapping.getInput());
}
//pour gérer l'anomalie du tableau qui est tjrs affiché !!
// "request" au lieu de "session"
request.setAttribute("templatesCollection", templates);
return mapping.findForward("success");
}
catch (Exception e) {
logger.warn(30070, "Erreur lors de la recherche de templates: " + e);
errors.add("error_service_search", new ActionMessage("error.template.search"));
saveMessages(request, (ActionMessages) errors);
return new ActionForward(mapping.getInput());
}
} |
Partager