Bonjour
Mon problème est que ma méthode de mon formulaire n'est pas appelée, J'ai un formulaire qui demande 2 date et puis il y a deux boutons, un pour valider et l'autre pour annuler. Quand je clic sur valider, rien ne se passe et mon modal panel se ferme sans accéder à la méthode sur l'action.
1 2 3 4 5
| <managed-bean>
<managed-bean-name>dateAbsenceBean</managed-bean-name>
<managed-bean-class>com.follo.abs.bean.DateAbsenceBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean> |
Le modal panel
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| <rich:modalPanel id="absencePrevuBox" minHeight="400" minWidth="400" height="400" width="400" zindex="2000">
<f:facet name="header">
<h:outputText value="Confirmation" />
</f:facet>
<f:facet name="controls">
<a4j:form>
<h:graphicImage value="/pages/images/close.png" style="cursor:pointer">
<a4j:support event="onclick" oncomplete="javascript:Richfaces.hideModalPanel('absencePrevuBox')" />
</h:graphicImage>
</a4j:form>
</f:facet>
<table>
<tr>
<td><h:graphicImage alt="warning" url="/pages/images/warning.png" /></td>
<td>
<h:outputText value="Choississez la date de départ et la date de fin pour votre absence" style="font-weight:bold; font-size: 14px;"/>
<br />
<br />
<br />
</td>
</tr>
</table>
<table width="100%">
<tr>
<td><h:outputText value="Début" /></td>
<td>
<rich:calendar id="myCalendarDebutAbs" popup="true" locale="#{dateAbsenceBean.locale}"
value="#{dateAbsenceBean.dateDebut}" datePattern="#{dateAbsenceBean.pattern}"
jointPoint="top-right">
<!-- Customization with usage of facets and accessible elements -->
<f:facet name="header">
<h:outputText value="{currentMonthControl}" style="font-weight:bold;text-align:center;"/>
</f:facet>
<f:facet name="weekDay">
<h:panelGroup style="width:15px; overflow:hidden;" layout="block">
<h:outputText value="{weekDayLabelShort}"/>
</h:panelGroup>
</f:facet>
<f:facet name="weekNumber">
<h:panelGroup>
<h:outputText value="{weekNumber}" style="color:red;width:15px;"/>
</h:panelGroup>
</f:facet>
<f:facet name="footer">
<h:outputText value="" />
</f:facet>
<h:outputText value="{day}"></h:outputText>
</rich:calendar>
</td>
<td rowspan="3" style="text-align:center;width:40%">
<h:graphicImage alt="calendrier" url="/pages/images/calendrier.jpg"/>
</td>
</tr>
<tr>
<td colspan="2"><br /><br />
<table>
<tr>
<td>Débute le matin : </td>
<td><h:selectBooleanCheckbox value="#{dateAbsenceBean.startMorning}" /></td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="2"><br /><br /><br /><br /></td></tr>
<tr>
<td><h:outputText value="Fin" /></td>
<td>
<rich:calendar id="myCalendarFinAbs" popup="true" locale="#{dateAbsenceBean.locale}"
value="#{dateAbsenceBean.dateFin}" datePattern="#{dateAbsenceBean.pattern}"
jointPoint="bottom-right" direction="top-right">
<!-- Customization with usage of facets and accessible elements -->
<f:facet name="header">
<h:outputText value="{currentMonthControl}" style="font-weight:bold;text-align:center;"/>
</f:facet>
<f:facet name="weekDay">
<h:panelGroup style="width:20px; overflow:hidden;" layout="block">
<h:outputText value="{weekDayLabelShort}"/>
</h:panelGroup>
</f:facet>
<f:facet name="weekNumber">
<h:panelGroup>
<h:outputText value="{weekNumber}" style="color:red"/>
</h:panelGroup>
</f:facet>
<f:facet name="footer">
<h:outputText value="" />
</f:facet>
<h:outputText value="{day}"></h:outputText>
</rich:calendar>
<br />
</td>
</tr>
<tr>
<td colspan="2"><br /><br />
<table>
<tr>
<td>Se termine le matin : </td>
<td><h:selectBooleanCheckbox value="#{dateAbsenceBean.endMorning}" /></td>
</tr>
</table>
</td>
</tr>
</table>
<a4j:form>
<p align="center">
<a4j:commandButton value="Sauvegarder" action="#{dateAbsenceBean.modifDateAbsence}" oncomplete="javascript:Richfaces.hideModalPanel('absencePrevuBox')" reRender="selectAnneeAbs, absenceTab, absDrag"/>
<a4j:commandButton value="Annuller" oncomplete="javascript:Richfaces.hideModalPanel('absencePrevuBox')" />
</p>
</a4j:form>
</rich:modalPanel> |
la ligne de l'action
<a4j:commandButton value="Sauvegarder" action="#{dateAbsenceBean.modifDateAbsence}" oncomplete="javascript:Richfaces.hideModalPanel('absencePrevuBox')" reRender="selectAnneeAbs, absenceTab, absDrag"/>
Mon bean
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| package com.follo.abs.bean;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import javax.faces.context.FacesContext;
public class DateAbsenceBean {
private Date dateDebut = null;
private Date dateFin = null;
private Locale locale = Locale.FRANCE;
private String pattern = "dd/MM/yy";
private boolean error = false;
private String errorMessage = null;
private boolean startMorning = true;
private boolean endMorning = false;
public DateAbsenceBean(){
super();
FacesContext facesContext = FacesContext.getCurrentInstance();
AbsenceBean absenceBean = (AbsenceBean)
facesContext.getExternalContext().getSessionMap().get("absenceBean");
setInitialDate(absenceBean.getAnneeCourante().intValue());
}
/* *********************************************** */
/* Listener */
/* *********************************************** */
public void modifDateAbsence(){
System.out.println("test valid date 1 ");
//Test si la date de fin et plus grande que la date de début
if(this.dateDebut.after(this.dateFin)){
this.errorMessage = "Erreur dans le choix de la date";
this.error= true;
}else{
//Récupération de la liste de zone
FacesContext facesContext = FacesContext.getCurrentInstance();
AbsenceBean absenceBean = (AbsenceBean)
facesContext.getExternalContext().getSessionMap().get("absenceBean");
System.out.println("test valid date");
absenceBean.validDrop(this.dateDebut, this.startMorning, this.dateFin, this.endMorning);
}
}
//Initialisation du calendrier au bon mois
public void setInitialDate(int annee){
GregorianCalendar cg = new GregorianCalendar();
cg.set(GregorianCalendar.YEAR, annee);
cg.set(GregorianCalendar.DATE, 1);
this.dateDebut = cg.getTime();
this.dateFin = cg.getTime();
}
/* *********************************************** */
/* Getter and Setter */
/* *********************************************** */
public Date getDateDebut()
{
return dateDebut;
}
public void setDateDebut(Date dateDebut)
{
this.dateDebut = dateDebut;
}
public Date getDateFin()
{
return dateFin;
}
public void setDateFin(Date dateFin)
{
this.dateFin = dateFin;
}
public Locale getLocale()
{
return locale;
}
public String getPattern()
{
return pattern;
}
public String getErrorMessage()
{
return errorMessage;
}
public void setErrorMessage(String errorMessage)
{
this.errorMessage = errorMessage;
}
public boolean isError()
{
return error;
}
public void setError(boolean error)
{
this.error = error;
}
public boolean isStartMorning() {
return startMorning;
}
public void setStartMorning(boolean startMorning) {
this.startMorning = startMorning;
}
public boolean isEndMorning() {
return endMorning;
}
public void setEndMorning(boolean endMorning) {
this.endMorning = endMorning;
}
} |
Partager