0

我有两个我想要的日历,当我在第一个 Schedule 中输入日期时,我会自动显示在第二个日历的文本区域中。我尝试使用此代码但没有结果:

<dd>
  <f:validateBean validationGroups="#{param['validationGroup']}">
    <p:calendar id="debutSortie" showOn="focus" locale="fr" pattern="dd/MM/yyyy"    value="#{AAA.dateDebut}" styleClass="datepicker">
      <p:ajax event="keyup" update="formDate:dateFin"/>
    </p:calendar>

    <h:graphicImage styleClass="js-datepicker-focus" width="19" height="19"
        alt="Voir le calendrier" value="/statique/images/pictos/picto_calendrier.png"/>
  </f:validateBean>
</dd>

<dt>
  <h:outputLabel for="finSortie_input">Date Fin : </h:outputLabel>
</dt>

<dd>
  <f:validateBean validationGroups="#{param['validationGroup']}">
    <p:calendar id="dateFin" showOn="focus" locale="fr" value="#{AAA.dateFin}"  pattern="dd/MM/yyyy" styleClass="datepicker">
    </p:calendar>

    <h:graphicImage styleClass="js-datepicker-focus" width="19" height="19" alt="Voir le calendrier" value="/statique/images/pictos/picto_calendrier.png"/>
  </f:validateBean>
</dd>

我添加了这个方法来测试

public void dateChangedListener(DateSelectEvent event) {
    System.out.println("DateSelectEvent" +event.getDate());
}

但我有这个错误信息:

 javax.faces.FacesException: Method not found: bean@31f8fd9.dateChangedListener(javax.faces.event.AjaxBehaviorEvent) 
4

1 回答 1

0

Where are you telling the second calendar to update with the date of the first one? You're updating it, but with no value. The most straight forwarded way to do that is to call a listener into the server using ajax.

<p:ajax event="dateSelect" update="formDate:dateFin" listener="#{AAA.dateChangedListener}"/>

Handle it in this way:

public void dateChangedListener(){
   dateFin = new Date(dateDebut.getTime());
}

In the ajax call just update the second date with the first value.

于 2013-02-04T21:21:13.927 回答