p:日历值未使用 dateSelect 更新 [英] p:calendar value not updated with dateSelect

查看:25
本文介绍了p:日历值未使用 dateSelect 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 p:dialog 中有一个 p:calendar 组件.When dialog is shown it takes its value from property in back bean, but when a new date is selected, the SelectEvent arrived to the listener brings the old value and not the new selected date.下一个代码有什么问题?

I have got a p:calendar component inside a p:dialog one. When dialog is shown it takes its value from property in back bean, but when a new date is selected, the SelectEvent arrived to the listener brings the old value and not the new selected date. What is wrong on next code?

   <p:dialog id="eventDialog" widgetVar="eventDialog" header="#{textos.confirmarFechaHora}" showEffect="clip" 
         hideEffect="clip" modal="true"
         appendToBody="true"> <!-- A false, no entran los eventos tras modificar la fecha/hora del calendario --> 
  <h:panelGrid id="eventDetails" columns="2">  
     <h:outputLabel for="calHora" value="#{textos.horaComienzo}" />  
     <p:calendar id="calHora" locale="es" pattern="dd/MM/yyyy HH:mm" 
                 value="#{schedulePFController.fechaComienzo}" mode="inline"
                 required="true"
                 accesskey="true" valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}">
        <p:ajax event="dateSelect" listener="#{schedulePFController.cambiaHoraComienzo}"/>
     </p:calendar>
     <p:commandButton value="#{textos.cancelar}" oncomplete="eventDialog.hide();"/>  
     <p:commandButton value="#{textos.mostrarCitas}" 
                      action="#{schedulePFController.verEntradaCalendario}" 
                      rendered="#{schedulePFController.clickedOnCita}"/>
     <p:commandButton value="#{textos.addCita}" 
                      action="#{schedulePFController.addCita}" 
                      rendered="#{!schedulePFController.clickedOnCita}"/>
  </h:panelGrid>

public void cambiaHoraComienzo(SelectEvent ev) {
  Date date = (Date)ev.getObject();
  fechaComienzo = date;
  horaComienzo = new DateCita(date);
  logger.debug("Cambiando fechaComienzo "+horaComienzo.toString()+" +++++++++++++++++++++++++++++++++++++++++");}

推荐答案

你这样做错了,太复杂了.

You are doing this the wrong way, to complicated.

看这里:

        <p:calendar value="#{ivkDaten.beginn}" locale="de" lang="de"
            pattern="dd.MM.yyyy" label="#{messages['services.ivk.beginn']}:" 
            width="80" id="ivkbeginn" effect="fadeIn" readonlyInput="true" disabled="true"
            showOn="button" mindate="#{services.minDate}" maxdate="#{services.maxDate}">

            <p:ajax event="dateSelect" listener="#{ivkDaten.recalcDate()}"
                update="ablauf" />
        </p:calendar>

您需要为 beginn 设置 getter/setter,当您调用方法 "reclacDate()" 时,您可以使用 beginn 和 i'我很确定你会有新的约会.

You need to set getter/setter for beginn and when you call the method "reclacDate()" you can use beginn and i'm pretty sure you will have the new date.

这篇关于p:日历值未使用 dateSelect 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆