14 Replies Latest reply on Jul 8, 2008 6:52 PM by PaKo

    setActionListener with showPopupBehavior not working?

    PaKo
      Hi!

      I have following piece of code:
       <af:commandImageLink id="ci1" icon="pop.png" clientComponent="true" partialSubmit="true">
            <af:showPopupBehavior popupId="myPopup"/>
      <af:setActionListener from="#{bindings.item.id}" to="#{pageFlowScope.id}"/>
      </af:commandImageLink>
      But, the setActionListener is not executed. If I drop the showPopupBehavior – it works as expected. So, it looks like showPopupBehavior and setActionListener are not fitting together. True? I don't recall any mention of this restriction in docs. Is this "by design" behavior or some bug?

      Regards,

      Pavle
        • 1. Re: setActionListener with showPopupBehavior not working?
          487442
          Hi Pavle,

          I believe it's by design as showPopupBehavior is mostly client side while setActionListener is solely server side, and popup content fetching is also evaluation during apply request values if I'm not wrong which is before invoke application in which setActionListener get called. Your use case can probably be achieved with a combo of client/serverListener along with clientAttribute though. With a bit more detail I might be able to come up with something more precise.

          p.s. Weird, was there a forum rollback during the weekend? I ask because I already answered this post Saturday and it was another forum engine, was there a bug or anything?


          Regards,

          ~ Simon
          • 2. Re: setActionListener with showPopupBehavior not working?
            PaKo
            Hi Simon!

            Yes, it looks like they rolled back whole Forum! Silly indeed. Maybe they just wanted to show us how it looks like when you lose your corporate knowledge? Good demonstration – so we all hurry to buy Beehive (for 50K instead of good-old OCS which was 1000x cheaper). Ok, we learned our lesson. Now they can "restore" our lost posts so we can continue with our business here.

            Cheers,
            Pavle
            P.S. If you don't see this post in next few days, don't be alerted - your eyes and state of mind is most probably OK, it's just Oracle managing something in their well-planned manner again.
            • 3. Re: setActionListener with showPopupBehavior not working?
              PaKo
              P.P.S. If you wonder if they rolled back the Price List also :))) No, they didn't. It was just a Forum...
              • 4. Re: setActionListener with showPopupBehavior not working?
                577304
                Hi Pako
                Try it this way

                <af:commandImageLink id="ci1" icon="pop.png" clientComponent="true" partialSubmit="true">
                     <af:showPopupBehavior popupId="myPopup" triggerType="click"/>
                <af:setActionListener from="#{bindings.item.id}" to="#{pageFlowScope.id}"/>
                </af:commandImageLink>

                Regards,
                JavaDeVeloper
                • 5. Re: setActionListener with showPopupBehavior not working?
                  PaKo
                  Hi Don!

                  Yes, it works!

                  Now, regarding Frank's and Simon's posts (which are not visible any more, but they stated that this cannot work because showPopup is client-side behavior and setActionListener is server-side so they collide in some way attached to same action source), I'm not sure if this is just a glitch that works or is "by design" behavior? This is very important use-case so I would like to hear more from you but also from Simon and Frank.

                  Thanks again for great tip!

                  Pavle
                  • 6. Re: setActionListener with showPopupBehavior not working?
                    Frank Nimphius-Oracle
                    Hi,

                    I admit that it is a bit confusing because it appears that setting the showPopupBehavior trigger type to "click" makes the whole thing work (even the action listener on the command component property palette works).

                    Setting the trigger type "action" doesn't work (Pako, which also is why your initial example doesn't work because the default is "action) for both, set af:setActionListener and the action listener set on the component property palette.

                    Here's my assumption of what is happening:

                    Using the showPopup with a trigger type of "action" will prevent any action or action listener from working because the showPopupBehavior cancels the event propagation for the action event. However, using a click as the trigger type on the showPopup behavior doesn't conflic with the action event (which is the event that gets cancelled) and thus both, the action listener events on the component and the setActionListener is fired.


                    I'll check with development and if I am right will file a documentation bug to have the documentation describing this accordingly

                    Frank

                    Ps.: I checked with a later build than TP4, so what you guys see in TP4 continues working
                    • 7. Re: setActionListener with showPopupBehavior not working?
                      487442
                      Hi,

                      It's great that it works, but I really wonder if it was willingly meant to, it's still a nice side effect however as it saves a very decent amount of lines of code.


                      ~ Simon
                      • 8. Re: setActionListener with showPopupBehavior not working?
                        PaKo
                        Hi!

                        That is exactly my question. Is this intended behavior? Looking into AdfShowPopupBehavior.js in adf-richclient-impl-11.jar I found this:
                        /**
                         * As part of the client behavior contract, initialize is called
                         * when the component is created to give the behavior a chance
                         * to register event listeners.
                         * @param {AdfComponent} component command family component
                         */
                        AdfShowPopupBehavior.prototype.initialize = function(component)
                        {
                          var type = this._type;
                          if (!type)
                          {
                            // We show our popup in response to action events.
                            // =-=ags todo Check that component supports action events?
                            type = AdfActionEvent.ACTION_EVENT_TYPE
                          }
                          else if (type == "mouseHover")
                          {
                            type = AdfUIInputEvent.MOUSE_IN_EVENT_TYPE;
                          }
                        
                          // simple event type listener:
                          component.addEventListener(type, this.fire, this);
                        }
                        If you pay attention, you will see that type=click is not handled properly - and it looks like it works just for that reasons!

                        It would be very nice if it is confirmed that triggerType=click is compatible with setActionListener. Also, I notice that even writing my own clientListener requires not to use event.cancel() after opening popup (with default triggerType=action) even in Frank's blog all sample for opening popup end with event.cancel().

                        Regards,
                        Pavle
                        • 9. Re: setActionListener with showPopupBehavior not working?
                          487442
                          Well, I think it COULD cause some side effects, especially if there are some components depending on the link through partialTriggers or a specified action (then again the latter would be silly), but that's only a theoretical concern on my side as I didn't build any test case.


                          ~ Simon
                          • 10. Re: setActionListener with showPopupBehavior not working?
                            Frank Nimphius-Oracle
                            Pako,

                            I am checking it.

                            ".. even in Frank's blog all sample for opening popup end with event.cancel()"

                            its my lazyness : - ) using event.cancel() puts me on the safe side and I don't have to test if a specific event continues bubbling up.

                            Frank
                            • 11. Re: setActionListener with showPopupBehavior not working?
                              PaKo
                              Simon,

                              this is very fuzzy issue. I think that showPopupBehavior should not even have triggerType=action. It really doesn't have much sense. The action (navigation) should not be performed if the popup is supposed to rise (this is actualy hov it works now, and it is obviously achieved with event.cancel() somwhere). I cannot imagine use-case where it is reasonable to have both showPopup and action navigation – except if they would like to support background navigation in view while (modeless) popup is opened in foreground. But this is very rare use-case, in contrast to very common need for setActionListener and showPopupBehavior join operation (for region binding as in my test case).

                              Pavle
                              • 12. Re: setActionListener with showPopupBehavior not working?
                                Frank Nimphius-Oracle
                                Pako, Simon,

                                I filed a bug against the click behavior. The "click" should be cancelled internally, which is the desired behavior by design. In other words, after fixing the this bug, the documentation is correct again that a clientListener should be used.

                                Frank
                                • 13. Re: setActionListener with showPopupBehavior not working?
                                  487442
                                  Thanks Frank, that information will prevent us from implementing something that won't work in future releases.


                                  ~ Simon
                                  • 14. Re: setActionListener with showPopupBehavior not working?
                                    PaKo
                                    Hi Frank!

                                    Thank you for update.

                                    Still, I don't understand how "design" is to break something that works in favor to something that we should work-around by more coding...

                                    For me, default triggerType=action is a BUG as I can't see use-case where you will open popup and navigate to other page in same time. On the other hand, trrigerType=click works as logically expected even now. I can agree that click should not work with setActionListener but it should work with setPropertyListener (a novel component in TP4 that exposes just needed behaviors). So, the fix is not to break something that works but to provide declarative way of setting things prior to opening popups (utilizing setPropertyListener).

                                    Please, don't overlook importance of this issue as it is very common use-case related to reusability of taskflows/regions in popups, which is one of flagship concepts in ADF RC compared to some other frameworks. So, don't shoot in your own leg by neglecting "small" things like this declarative support for popup parameters preparation.

                                    Regards,

                                    Pavle