You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Xavier Ottolini <xa...@yahoo.fr> on 2010/03/23 15:44:40 UTC
question
Hi,
I tried to display error messages in my JSP, I put on the JSP the tag :
<html:errors header="errors.header" footer="errors.footer" prefix="errors.prefix" suffix="errors.suffix" />
In the MessageRessources.properties, I created the following entries :
errors.header=<div class="errors">
errors.footer=</div>
errors.prefix=<div>
errors.suffix=</div>
error.technique=Problème technique {0}
error.utilisateurdoublon=L'utilisateur existe déjà
The errors header and footer is not customized. And I do not understant why.
In my struts-config.xml, I declared the MessageRessources.properties file :
<message-resources parameter="fr.documentfacturationdcp.MessageResources"/>
In the Action class, I do the following process :
package fr.postgresqldocumentfacturationdcp.webapp;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import fr.postgresqldocumentfacturationdcp.domaine.Administrateur;
import fr.postgresqldocumentfacturationdcp.domaine.Utilisateur;
import fr.postgresqldocumentfacturationdcp.metier.GestionAdministrateur;
import fr.postgresqldocumentfacturationdcp.vue.AdministrateurForm;
import fr.ouestfrance.evno.metier.exception.FunctionalException;
public class AjouterAdministrateurAction extends Action {
public AjouterAdministrateurAction() {
super();
}
public ActionForward execute(ActionMapping pMapping, ActionForm pForm, HttpServletRequest pRequest,
HttpServletResponse pResponse) throws Exception {
ActionErrors vErrors = new ActionErrors();
ActionForward vActionForward;
try {
AdministrateurForm vForm = (AdministrateurForm) pForm;
if (...) {
ActionMessage vMessage = new ActionMessage("error.utilisateurdoublon");
vErrors.add("logique", vMessage);
saveErrors(pRequest, vErrors);
vActionForward = pMapping.findForward("erreur");
}
...
vActionForward = pMapping.findForward("validation");
} catch (FunctionalException vFex) {
ActionMessage vMessageErreur = new ActionMessage("error.technique", vFex.getMessage());
vErrors.add("technique", vMessageErreur);
saveErrors(pRequest, vErrors);
vActionForward = pMapping.findForward("erreur");
}
return vActionForward;
}
}
The HTML code generated when an error is raised is the following :
<table><tr><td>L'utilisateur existe déjà</td></tr><tr><td>Problème technique L'utilisateur 123450 existe déjà</td></tr></table>
Have you got any idea why the errors.header, errors.footer, errors.prefix, errors.suffix keys of the MessageRessources are not used ? What should I do ?
The other keys of the MessageRessources are displayed without any problem.
Any help would be appreciated.
Regards.
Xavier
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org