5 Replies Latest reply on Feb 2, 2012 10:19 AM by elharrathi

    rich:calendar firing onchange event

    elharrathi

      hi,

      i have two rich:calendar .on the second one i have validator.the validator is working well.

      i want that if Date changed onrich:calendar1 i invoque the change event of the second rich:calendar so i invoque the validator.

      i have no idea how it must be done. i have tryed with javascript but it's not working.

      any help will be appreciated

       

      the first rich:calendar:

      <rich:calendar id="calendarDeb" name="calendarDeb" popup="true"

                                  showApplyButton="true" cellWidth="24px" cellHeight="22px"

                                  style="width:200px" value="#{vehiculeFilterBean.dateDebut}"

                                  required="true" requiredMessage="le champ date  debut est obligatoir"

                                  converterMessage="le champ date debut doit etre de la forme dd/mm/yyyy"

                                  binding="#{calendarDeb}"

                                  datePattern="dd/MM/yyyy"

                                  >

                                  <a4j:ajax  event="change"   oncomplete="window.alert('i work');#{rich:component('evnt')}.change();">

                                  </a4j:ajax>

                              <f:convertDateTime type="date" pattern="dd/mm/yyyy" />

                              </rich:calendar >

       

      and the second rich:calandar:

       

      <rich:calendar id="calendarFin" name="calendarFin" popup="true"

                                  showApplyButton="true" cellWidth="24px" cellHeight="22px"

                                  style="width:200px" value="#{vehiculeFilterBean.dateFin}"

                                  required="true" requiredMessage="le champ date Fin est obligatoir"

                                  converterMessage="le champ date fin doit etre de la forme dd/mm/yyyy"

                                  binding="#{calendarFin}" validator="#{vehiculeFilterBean.validerdate}"

                                  datePattern="dd/MM/yyyy"

                                  >

                                  <a4j:ajax id="evnt" event="change"   listener="#{vehiculeFilterBean.validerdate}">

                                  </a4j:ajax>

                                  <f:attribute name="calendarDeb" value="#{calendarDeb}"></f:attribute>

                                  <f:convertDateTime type="date" pattern="dd/mm/yyyy"/>

                              </rich:calendar>

       

      i(m orking with JSF and RichFaces 4.0 final

      thinks

        • 1. Re: rich:calendar firing onchange event
          mcmurdosound

          Since RF 4 comes with a quite recent jQuery version (in comparison with RF 3.3.3), you could use jQuery trigger (http://api.jquery.com/trigger/) to trigger the onchange event of the second calendar (not the a4j:ajax!). This might work. I haven't tried this one...

          • 2. Re: rich:calendar firing onchange event
            mcmurdosound

            Hmmmm it's a bit tricky. You'll have to enable manual input for the calendars, then add a valueChangeListener and add an a4j:ajax with inputchange event:

             

            <rich:calendar id="mycaltwo" value="#{myMBean.myDateTwo}" styleClass="secondcal"

                                   enableManualInput="true" valueChangeListener="#{myMBean.vcl}">

                       

                        <a4j:ajax event="change" listener="#{myMBean.myListener}"/>

                       

                        <a4j:ajax event="inputchange" listener="#{myMBean.myListener}"/>

            </rich:calendar>

             

            to trigger the calendars event:

             

            jQuery(".secondcal").find('input[type=text]').trigger('onchange');

             

             

            You could use IDs here...

             

            Strange effect: the inputchange bound listener won't be called. But since you're only interested in validation, this should not matter. This event is needed to have something triggerable for jQuery.

            • 3. Re: rich:calendar firing onchange event
              elharrathi

              thanks for the responce and sorry for the delay.

              i have changed the way of how it work so i haven 't tested it.hope this help other poeple.

              thanks again

              • 4. Re: rich:calendar firing onchange event
                fernandoabreu

                Have you tried :

                 

                <rich:calendar id="mycaltwo" value="#{myMBean.myDateTwo}" styleClass="secondcal">

                            <a4j:ajax event="ondateselected" action="#{myMBean.myAction}"/>

                </rich:calendar>

                 

                It works for me.

                Fernando

                • 5. Re: rich:calendar firing onchange event
                  elharrathi

                  think you Fernando for the  replay.

                  this will maybe help another one cause i have changed the way how it work.