9 Replies Latest reply on Apr 20, 2010 4:58 AM by Ilya Shaikovsky

    rich:calendar currentDate dataTable select only the month not the day

    samuel contreras Novice

      hi all, i have a problem using the rich:calendar inside of a dataTable. I do an action and in my Backing Bean the property of the currentDate from my rich:calendar render me only the month, i need the day too . but the day is always the same 1° for example i select Aug 16 in rich:calendar and the get property in my backing bean is:(Sun Aug 01 00:00:00 CDT 2010)


      the code in my jsf is the next:

       

      <rich:dataTable id="actProdData" var="actProdItem" value="#{ActProdBean.lstActCampDetail}">

          <h:column>
              <f:facet name="header">
                  <h:outputText value="Expiration Date"/>
              </f:facet>
                  <rich:calendar  id="calendarProd" datePattern="dd/MM/yyyy" value="#{actProdItem.datExpDate}" reRender="actProdData"                                   currentDate="#{Broker.dateCalendarChange}">
                                <a4j:support event="onchanged" action="#{OrganizerBean.upDateProdDetail}" reRender="actProdData" />
                  </rich:calendar>

          </h:column>

      </rich:dataTable>


      the code in my backing bean is:

       

      public void upDateProdDetail() throws Exception {   
              Date listenerDate = (Date)Broker.getDateCalendarChange();
      }

       

      thanks so much

        • 1. Re: rich:calendar currentDate dataTable select only the month not the day
          Ilya Shaikovsky Master

          currentDate - always contains the dirst day as it used to define current month. Use value binging..

          • 2. Re: rich:calendar currentDate dataTable select only the month not the day
            samuel contreras Novice

            hi Ilya and thanks 4 your answer, ok, i used the value for obtain the day and the month and all is fine, but here ir another question i´ve add another column beacause when i try to do the getDatExpDate from de bean ActProdBean is null, i think is because the actProdItem.datExpDate is inside from the lstActCampDetail, so i´ve create another property Broker.dateCalendarChange and the getDateCalendarChange work very well.

            but how can I obtain the value from the actProdItem.datExpDate

             


            the code with the new colum:

             

            <rich:dataTable  id="actProdData" var="actProdItem"  value="#{ActProdBean.lstActCampDetail}">

                <h:column>
                     <f:facet name="header">
                        <h:outputText  value="Expiration Date"/>
                    </f:facet>
                         <rich:calendar  id="calendarProd" datePattern="dd/MM/yyyy"  value="#{actProdItem.datExpDate}" >
                                       <a4j:support event="onchanged"  action="#{OrganizerBean.upDateProdDetail}" reRender="actProdData" />
                         </rich:calendar>

                </h:column>

             

                 <h:column>
                        <f:facet name="header">
                             <h:outputText value="Change Expiration Date"/>
                          </f:facet>
                                      <rich:calendar value="#{Broker.dateCalendarChange}" datePattern="dd/MM/yyyy">
                                           <a4j:support event="onchanged" action="#{OrganizerBean.upDateProdDetail}">
                                               <f:param name="idActivity" value="#{actProdItem.lstActId}"></f:param>
                                           </a4j:support>
                                   </rich:calendar>
                 </h:column>

            </rich:dataTable>

             

             

            thanks Ilya

            • 3. Re: rich:calendar currentDate dataTable select only the month not the day
              Ilya Shaikovsky Master

              actually you could use actionListener at support or valueChangeListener at calendar. In this case you will get Event source component and could easilly obtain value from this object.

              1 of 1 people found this helpful
              • 4. Re: rich:calendar currentDate dataTable select only the month not the day
                samuel contreras Novice

                Another point. when the the list in rich:dataTable bring me more than one row i can´t obtain the value from the bean, only the last row obtain the value from the date selected, but the first, second... don´t do it

                 

                rich_calendar.PNG

                • 5. Re: rich:calendar currentDate dataTable select only the month not the day
                  Ilya Shaikovsky Master

                  mapping inputs in iteration components to the single property has no sence and the result (all the components stores it's values to the same property) - seems just as it should

                  • 6. Re: rich:calendar currentDate dataTable select only the month not the day
                    samuel contreras Novice

                    hi again Ilya, i used the <a4j:support... but the value of the valueChangeListener is null yet   i dont found my error. how i can obtain the date select???

                     

                    here is my calendar

                     

                                    <rich:dataTable id="actProdData" var="actProdItem" value="#{ActProdBean.lstActCampDetail}" headerClass="textHeader" rows="8">

                                        <h:column>
                                           <f:facet name="header">
                                              <h:outputText value="Change Expiration Date"/>
                                           </f:facet>
                                           <rich:calendar value="#{actProdItem.datExpDate}" datePattern="dd/MM/yyyy" >
                                               <a4j:support event="ondateselect" actionListener="#{OrganizerBean.upDateProdDetail}"></a4j:support>   
                                           </rich:calendar>
                                       </h:column>
                                     </rich:dataTable>

                     


                    here is my method:

                     

                    public void upDateProdDetail(ActionEvent event) throws Exception {   
                            System.out.println("get the event for the component");
                        }

                     

                    the  result when i debug

                    valueListener_null.PNG

                    • 7. Re: rich:calendar currentDate dataTable select only the month not the day
                      Nick Belaevski Master

                      Hi,

                       

                      a4j:support is a separate component that has its own listener(s). You should define value change listener method on calendar tag explicitly if you need it also.

                      • 8. Re: rich:calendar currentDate dataTable select only the month not the day
                        samuel contreras Novice

                        i used <a4j:support... because valueChangeListener dont trigger the method

                         

                        <rich:calendar value="#{actProdItem.datExpDate}" datePattern="dd/MM/yyyy" valueChangeListener="#{OrganizerBean.upDateProdDetail}">

                         

                         

                        public void upDateProdDetail(ValueChangeEvent event) throws Exception {   

                                System.out.println("Method ");

                            }

                        • 9. Re: rich:calendar currentDate dataTable select only the month not the day
                          Ilya Shaikovsky Master

                          actually seems the last step remained

                           

                          return support back without any listeners and remain valueChangeListener defined.

                           

                          The last code will not wors as there is just no requests.. So after you add support back it will rise requests and calendar will queue ValueChangeEvent when value is changed so you will be able to handle.