Hi, I need to do something that looks very simple to me : - a form with a select list - the data in the list comes from database - when submitting the form, I want to validate datas. If it doesn't validate, I display the form again
I configured two actions : - An "init" action, that loads data from the database and redirects to the JSP page - A "submit" action, that validates datas and writes data in the database <package name="absences" namespace="/absences" extends="struts-default"> <action name="initCreerDemandeAbsence" class="creerDemandeAbsenceAction" method="init"> <result name="success">/jsp/absences/creerDemandeAbsence.jsp</result> </action> <action name="submitCreerDemandeAbsence" class="creerDemandeAbsenceAction"> <interceptor-ref name="defaultStack" /> <result name="input">/absences/initCreerDemandeAbsence.action</result> <result name="success">/jsp/absences/confirmerCreationDemandeAbsence.jsp</result> </action> </package> </struts> My action class extends ActionSupport and contains variables and the following methods : public String init() throws Exception { this.motifs = getServiceAbsence().getAllMotifsAbsence(); return SUCCESS; } public String execute() throws Exception { demandeAbsence.setMatriculeAuteur(SecurityContextHolder.getContext ().getAuthentication().getName()); demandeAbsence.setVisa(VisaDemande.VISA_ATTENTE.getValue()); demandeAbsence.setLignes(new VOLigneDemandeAbsence[]{getLigneDemandeAbsence()}); demandeAbsence = getServiceAbsence().createDemande(demandeAbsence); return SUCCESS; } And my JSP page is as following : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <[EMAIL PROTECTED] contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Demande d'absence</title> <s:head theme="ajax" /> </head> <body> <s:actionerror /> <s:form action="submitCreerDemandeAbsence" id="form1" validate="false" method="post"> <s:datetimepicker name="demandeAbsence.dateDemande" label="Date de la demande" required="true" requiredposition="left" displayFormat="dd/MM/yyyy" /> .... <s:select name="ligneDemandeAbsence.motif" label="Motif" list="motifs" listKey="nom" listValue="nom" headerKey="" headerValue="--- Sélectionnez un motif ---" required="true" requiredposition="left" /> .... <s:submit type="button" theme="xhtml" /> </s:form> </body> </html> But it doesn't work this way : when there are validation errors, I have a 404 HTTP error when trying to redirect to "initCreerDemandeAbsence" action (I need to do this to have the select list datas loaded from database). In fact it works only when I set a JSP page as result ... Anyone knows how to set an action as an input result rather than a JSP page ? And are there better practices to do what I want ? Thanks in advance Olivier