1 2 Previous Next 19 Replies Latest reply on Jun 15, 2009 9:54 AM by elf

    Rich Calendar and Ajax support

    aboocs01

      hi,

      i want to make ajax request on the calendar selection

      Example:
      when i select date from rich:calendar , immediately ajax request need be call, take the selected date from there and give to another action java class...

      sp pls temme how to get the date from ajax....

        • 1. Re: Rich Calendar and Ajax support
          ilya_shaikovsky

          a4j:support event="onchanged" actionListener="#{bean.actionYouNeedToPerform}"

          :)

          • 2. Re: Rich Calendar and Ajax support
            aboocs01

            hi illa,
            thank you very much

            • 3. Re: Rich Calendar and Ajax support
              elf

              I have a problem with this. Only difference is I tried to do it programmatically. Event 'onchanged' fired only once when selected value is null. My code

               HtmlCalendar orgCal = new HtmlCalendar();
               orgCal.setPopup(false);
               orgCal.setValueExpression("value", eF.createValueExpression(eC, "#{bean.organizerDate}", Date.class));
              
               orgCal.setMode("ajax");
              
              
               HtmlAjaxSupport as = new HtmlAjaxSupport();
               as.setEvent("onchanged");
               as.addActionListener(new OrganizerValueChangeListener());
              
              
               orgCal.getChildren().add(as);


              I clicked on cells of calendar, ajax status said that request done, but listener called only first time. I tried to create ajax function and called it on onchanged event, tried to create ValueChangeListener and add it to orgCal object - but result is the same, event fired only once.

              Please help me, what I am doing wrong ?


              • 4. Re: Rich Calendar and Ajax support
                ilya_shaikovsky

                support should be added as a facet if added programmatically.

                • 5. Re: Rich Calendar and Ajax support
                  elf

                  Ilya, I added support object as facest under 'onchanged' key, but the result is the same. Only once event fired.
                  Is this key correct?

                  P.S. I have panelBar in sideBar, on one of the items of panelBar there is my calendar.

                  • 6. Re: Rich Calendar and Ajax support
                    ilya_shaikovsky

                    so.. requests risen but listener not called second time?

                    1) which scope your binding has?
                    2) if there are any messages in console?
                    3) add phasetracker in order to check lifecycle execution for second request.

                    • 7. Re: Rich Calendar and Ajax support
                      elf

                      1. session scope
                      2. in ajax log there is no errors or any suspicious messages
                      3. first time listener called in 5 phase, second time all 6 phases were executed
                      Should I check something else ?

                      • 8. Re: Rich Calendar and Ajax support
                        ilya_shaikovsky

                        1) binding should be request scoped. the reasons described many times at this forum. This is JSF related issue.

                        • 9. Re: Rich Calendar and Ajax support
                          elf

                          Are we talking about this part of code
                          orgCal.setValueExpression("value", eF.createValueExpression(eC, "#{bean.organizerDate}", Date.class));

                          Or should I assign 'binding' value for object ?

                          • 10. Re: Rich Calendar and Ajax support
                            ilya_shaikovsky

                            your Object which contains this binding property should be request scoped.

                            • 11. Re: Rich Calendar and Ajax support
                              elf

                              Ilya , I made my bean request scope, also I added code

                              
                              orgCal.setValueExpression("binding", eF.createValueExpression(eC, "#{bean.bindingObj}", UICalendar.class));
                              

                              but the result is the same.
                              What I am doing wrong ?
                              Did you try do run my code on your box ? It is simple non-popup calendar.

                              • 12. Re: Rich Calendar and Ajax support
                                elf

                                Looks like I found the problem.
                                I tried to add on my sideBar tree and it works not properly too.
                                So my creating of sideBar is wrong.
                                I did it in this way:
                                I created page in xhtml file. For creating sidebar I wrote

                                <f:facet name="sidebar">
                                <h:outputText value=""/>
                                </f:facet>
                                

                                In action I found page component by ID and did as
                                mypage.getFacets().put("sidebar", MY_SIDE_BAR);
                                

                                As MY_SIDE_BAR I tried to use AjaxForm with Calendar or tree inside, OutputPanel with AjaxForm and Calendar or tree inside.
                                In all my cases everything inside sideBar in this way created works wrong.
                                Help me please, what is the right way to create sideBar for page programmatically ? What I am doing wrong ?

                                • 13. Re: Rich Calendar and Ajax support
                                  nbelaevski

                                  Whom does "sidebar" facet belong to?

                                  • 14. Re: Rich Calendar and Ajax support
                                    elf

                                    I found UIComponent of my <rich:page ... id="my_page_id"> by id.
                                    "sidebar" facet belongs to this component.

                                    1 2 Previous Next