1 2 3 Previous Next 30 Replies Latest reply on Jun 6, 2007 2:38 PM by sergeysmirnov Go to original post
      • 15. Re: use ajax4jsf in existing custom jsf components
        grimholtz

        I've never done this before... can you point me to any further information? I see UIComponent.getAttributes(), and I suspect I must add onswitch to the Map returned by this method (among other things), but could really use some help...I'm googling and scanning through JSF books in meantime.

        • 16. Re: use ajax4jsf in existing custom jsf components
          grimholtz

           

          "grimholtz" wrote:
          I've never done this before... can you point me to any further information? I see UIComponent.getAttributes(), and I suspect I must add onswitch to the Map returned by this method (among other things), but could really use some help...I'm googling and scanning through JSF books in meantime.

          OK, so I added support for "onswitch" on the custom tag and in the component, but what kind of client-side code must I generate in order for <a4j:support/> to catch the event?

          • 17. Re: use ajax4jsf in existing custom jsf components

            check that your 'onswitch' is invoked when you press any button. I.e. ppp:selectManyPicklist onswitch="alert('works')"

            If it works, you can say a4j:support event="onswitch" reRender="pg1"

            • 18. Re: use ajax4jsf in existing custom jsf components
              grimholtz

               

              check that your 'onswitch' is invoked when you press any button

              Should this result in a form submit?

              • 19. Re: use ajax4jsf in existing custom jsf components

                Hmm. It looks like we are not on the same page.
                You need to invoke onswitch on the client side. It is not about form submitting at all.

                • 20. Re: use ajax4jsf in existing custom jsf components
                  grimholtz

                   

                  "SergeySmirnov" wrote:
                  Hmm. It looks like we are not on the same page.
                  You need to invoke onswitch on the client side. It is not about form submitting at all.

                  You mean a custom Javascript event object? Please, is there an example anywhere how to do this? I am having a difficult time...

                  • 21. Re: use ajax4jsf in existing custom jsf components
                    grimholtz

                     

                    "SergeySmirnov" wrote:
                    Hmm. It looks like we are not on the same page.
                    You need to invoke onswitch on the client side. It is not about form submitting at all.

                    You mean a custom Javascript event object? Please, is there an example anywhere how to do this? I am having a difficult time...

                    • 22. Re: use ajax4jsf in existing custom jsf components
                      grimholtz

                      I know how to write custom Javascript events. I know how to write custom server-side Faces events. Why can't I put this knowledge together to solve this problem?

                      • 23. Re: use ajax4jsf in existing custom jsf components

                        Curiously, you do not have to have both of them. I guess the task is much much simpler that you are trying to do. Did you add attribute with name 'onswitch' to your component?

                        • 24. Re: use ajax4jsf in existing custom jsf components
                          grimholtz

                           

                          "SergeySmirnov" wrote:
                          Curiously, you do not have to have both of them. I guess the task is much much simpler that you are trying to do. Did you add attribute with name 'onswitch' to your component?

                          Yes, I added that attribute. However, I need to know what the code behind rendering the value of that attribute should be. You said to make sure onswitch="alert('works')". However, this should only work when an < option/> moves from one < select/> to the other. So I have Javascript that, when the button is clicked, fires a Javascript 'switch' event. After your previous post, I see this isn't correct.

                          So I should just render the attribute value without any special handling? How does a4j bind to an option switching select boxes?

                          • 25. Re: use ajax4jsf in existing custom jsf components

                             

                            "grimholtz" wrote:
                            "SergeySmirnov" wrote:
                            So I have Javascript that, when the button is clicked, fires a Javascript 'switch' event. After your previous post, I see this isn't correct.

                            No. This is correct. You need to do so. If you see alert box clicking on any button, that is only what you need.


                            • 26. Re: use ajax4jsf in existing custom jsf components
                              grimholtz

                              I cannot get < a4j:support > to recognize the event. This might be an IE6 problem (IE6 doesn't support custom onmyevent="" attributes to < input> elements. However, it does support custom JS events and I have one firing when the < input> elements are clicked.

                              What JS can I write in my custom JS event handler to perform an ajax4jsf submit (as the a4j:support would do)?

                              Thanks,
                              grimholtz

                              • 27. Re: use ajax4jsf in existing custom jsf components
                                grimholtz

                                Another way of asking this question: can I get a4j:support to render target.addEventListener() or target.attachEvent() instead of onswitch="" attribute?

                                • 28. Re: use ajax4jsf in existing custom jsf components

                                  the answer in NO

                                  I am not sure I understand why you speak about IE6 and input. The onswitch should be the attribute of the top html element of your component. It is not an input for sure.

                                  • 29. Re: use ajax4jsf in existing custom jsf components
                                    grimholtz

                                    I got it working. I will write a tutorial for others. Sergey, you should know that as documented in "Javascript: The Definitive Guide, 5th Edition" (David Flanagan, August 2006, O'Reilly Publishing) Chapter 17.7 Synthetic ("Custom") Events:

                                    The DOM event model allows synthetic events of any type, but the IE model supports only synthetic events of predefined types. dataavailable events are the most generic predefined type supported by IE...

                                    (Code and comments here: http://safari.oreilly.com/0596101996/jscript5-CHP-17-SECT-7)

                                    This means a custom event named switch does not work in IE6. It produces a JS error when fireEvent() is called. I did not try with IE 7. Here is the list of pre-defined IE events: http://msdn2.microsoft.com/en-us/library/ms533051.aspx
                                    If you want this to work with IE6 (and possibly IE7--I didn't test that), you must make the onXXX() attribute handler generated by aj4:support a handler for one of these predefined events.

                                    Hope this helps someone. in the future.
                                    -grimholtz