1 2 3 Previous Next 44 Replies Latest reply on Feb 12, 2009 1:48 PM by ssilvert Go to original post
      • 15. Re: [IceFaces] NullPointerException when accessing JSFServer
        lightguard

         

        "russegan" wrote:

        I haven't tried it out yet, but I plan on either cloning or extending JsfUnit's JsfClientSession class, and overriding just the event handling, so it will ignore events coming from any window's besides the current window. I'm pretty sure that will fix that problem.


        That seems like a big hack :( I wonder if there's a better way we could do this.

        • 16. Re: [IceFaces] NullPointerException when accessing JSFServer
          ansel1

          Yeah, unfortunately, I couldn't see any way cleaner way to work around the problem. It really needs to be fixed in the JsfClientSession class. That event listener seems to be vulnerable to any webapp which has multiple windows open. It would flit back and forth between windows depending on the order of the window updated events coming in.

          • 17. Re: [IceFaces] NullPointerException when accessing JSFServer
            lightguard

            The iframe has an id of history-frame could we do some searching and just not return that window if we're using ICEfaces?

            • 18. Re: [IceFaces] NullPointerException when accessing JSFServer
              ansel1

              Isn't that too specific? That would only fix the problem with Icefaces. But in theory, any web app could have multiple windows like that. Ideally, JsfClientSession would allow the developer to pinpoint which windows he/she is interested in interacting with in their test. Either JsfClientSession should expose an API for interacting with different windows, or perhaps have multiple JsfClientSessions, each tied to a particular window.

              For example, in our IceFaces application we have just started using IceFace's concurrent DOM views feature. We'd need that kind of granular window control to write tests where we open multiple windows against the same session. Technically, JsfUnit already gives you this access, since JsfClientSession is just a very thin facade around the HtmlUnit APIs. You can just access those APIs directly, avoid JsfClientSession altogether. Maybe that is the intent? If your app uses more than one window, then you should just avoid JsfClientSession? Like its just a convenience API for single-window apps?

              • 19. Re: [IceFaces] NullPointerException when accessing JSFServer
                lightguard

                 

                "russegan" wrote:
                Isn't that too specific? That would only fix the problem with Icefaces. But in theory, any web app could have multiple windows like that. Ideally, JsfClientSession would allow the developer to pinpoint which windows he/she is interested in interacting with in their test. Either JsfClientSession should expose an API for interacting with different windows, or perhaps have multiple JsfClientSessions, each tied to a particular window.

                For example, in our IceFaces application we have just started using IceFace's concurrent DOM views feature. We'd need that kind of granular window control to write tests where we open multiple windows against the same session. Technically, JsfUnit already gives you this access, since JsfClientSession is just a very thin facade around the HtmlUnit APIs. You can just access those APIs directly, avoid JsfClientSession altogether. Maybe that is the intent? If your app uses more than one window, then you should just avoid JsfClientSession? Like its just a convenience API for single-window apps?


                They have said feel free to use the HTMLUnit API if you need to, but I do agree that JSFUnit should give you a way to work with multiples windows if your view spawns them. Stan, your views?

                I'd say make the changes and post up a diff or something and lets go from there (if you have the time) or just use HTMLUnit's API (but let the forum know which way you're leaning so we have answers :) )

                • 20. Re: [IceFaces] NullPointerException when accessing JSFServer
                  lightguard

                  Jumping into the code I would think it would make perfect sense for the JSFClientSession to keep a list of pages spawned by a WindowWebEvent and expose that to the user. Maybe that's really low level, but if I create a page that spawns some windows I'd probably like to have a reference to both the opener (or containing document in the case of an iframe) and the spawned window.

                  Maybe the JSFClientSession should have a list of pages and a setter method to switch the contentPage it's currently using. Then you'd need some way of determining when to flush that cache though...

                  Sorry, just thinking as I type. Feel free to comment.

                  • 21. Re: [IceFaces] NullPointerException when accessing JSFServer
                    ssilvert

                     

                    "Lightguard" wrote:
                    Jumping into the code I would think it would make perfect sense for the JSFClientSession to keep a list of pages spawned by a WindowWebEvent and expose that to the user. Maybe that's really low level, but if I create a page that spawns some windows I'd probably like to have a reference to both the opener (or containing document in the case of an iframe) and the spawned window.

                    Maybe the JSFClientSession should have a list of pages and a setter method to switch the contentPage it's currently using. Then you'd need some way of determining when to flush that cache though...


                    That sounds like the correct solution. Does ICEfaces maintain a simple demo WAR in a Maven repo somewhere? I could pull in the WAR and use it for testing this out.

                    Stan

                    • 22. Re: [IceFaces] NullPointerException when accessing JSFServer
                      ssilvert

                      I've opened a new Jira for this:
                      https://jira.jboss.org/jira/browse/JSFUNIT-191

                      Here is a proposed change to JSFClientSession. Please provide feedback.

                      Add these two methods:

                      public void setCurrentWindow(WebWindow window)
                      
                       public Iterator<WebWindow> getOpenWindows()


                      Furthermore, the current window will not change unless the user calls setCurrentWindow. However, if the current window closes, the current window will be set to the closing window's parent.

                      Is there a better name for "current window". "Active window" doesn't seem right. Does "current window" describe it properly?

                      BTW, here is the javadoc for WebWindow:
                      http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/WebWindow.html

                      Stan

                      • 23. Re: [IceFaces] NullPointerException when accessing JSFServer
                        lightguard

                         

                        "stan.silvert@jboss.com" wrote:
                        I've opened a new Jira for this:
                        https://jira.jboss.org/jira/browse/JSFUNIT-191

                        Here is a proposed change to JSFClientSession. Please provide feedback.

                        Add these two methods:
                        public void setCurrentWindow(WebWindow window)
                        
                         public Iterator<WebWindow> getOpenWindows()


                        Furthermore, the current window will not change unless the user calls setCurrentWindow. However, if the current window closes, the current window will be set to the closing window's parent.

                        Is there a better name for "current window". "Active window" doesn't seem right. Does "current window" describe it properly?

                        BTW, here is the javadoc for WebWindow:
                        http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/WebWindow.html

                        Stan


                        I'd make comments to the JIRA issue, but apparently my login doesn't have rights :( (be great if someone could fix that, user is LightGuard).

                        I think that sounds great Stan, should be what we're looking for in ICEfaces, and should help others as well.

                        ICEfaces does not have a war that they keep in Maven (maybe sometime this year, it was a closed source project which was released under the MPL and they're still looking at the legal ramifications of making source and examples available via Maven Repos). You can find the compiled jars in the Jboss repo: http://repository.jboss.org/maven2/org/icefaces/ (you'll need them all if you're using facelets). An example app that you can use is at http://www.icefaces.org/main/downloads/os-downloads.iface (you'll need a free login). Either one of the projects or the main downloads contain samples that you can use.

                        • 24. Re: [IceFaces] NullPointerException when accessing JSFServer
                          lightguard

                          I've been looking into things a bit on the ICEfaces side with the FacesContext and I'm not seeing anything wrong here (I had to do a lot of research into the RI code to see what's going on, because the JavaDocs don't really make things very easy to understand what's really happening). The ICEfaces FacesContext has the extra single arg constructor so it should be delegating. And I know that the JSFUnit has that constructor as well and the code looks good there also. I need to actually do some debugging (load up the RI code and ICEfaces code) to really see what's going on. If anyone has some of this information already, feel free to share :) Maybe we can get some of the ICEfaces people involved in the discussion as well.

                          • 25. Re: [IceFaces] NullPointerException when accessing JSFServer
                            ansel1

                            The problem is that the icefaces servlet bypasses the factories altogether. It directly instantiates an icefaces bridgefacescontext. Just search for all usages of the bridgefacescontext. I think I posted something about that earlier on this thread. We're getting around with a phaselistener, but stan tells me that probably isn't a very robust solution.

                            • 26. Re: [IceFaces] NullPointerException when accessing JSFServer
                              lightguard

                              Stan would be correct, unless you're listening to all phases and doing something tricky to know if you've already done what needed to be done.

                              We're hoping to get some people ICEfaces involved in this and see what the have to say.

                              • 27. Re: [IceFaces] NullPointerException when accessing JSFServer
                                ssilvert

                                I've uploaded a new set of snapshots to the repo. JSFClientSession now implements setCurrentWindow() and it ignores page changes unless the changed page comes from the current window.

                                You can get the latest from the JBoss snapshot repo:
                                http://snapshots.jboss.org/maven2/org/jboss/jsfunit/

                                This code is still not right. I've found timing issues that cause test failures. However, it does allow you to get started with IceFaces.

                                I have now added an IceFaces test to my test suite. It doesn't do much except verify that you can get the proper Page with JSFClientSession. I suspect that JSFServerSession is going to have problems with IceFaces down the road.

                                Stan

                                • 28. Re: [IceFaces] NullPointerException when accessing JSFServer
                                  lightguard

                                  Awesome Stan! How have you gotten past the FacesContext problem in your tests? What sort of issues do you foresee with ICEfaces and JSFServerSession?

                                  • 29. Re: [IceFaces] NullPointerException when accessing JSFServer
                                    ssilvert

                                    I haven't had a FacesContext problem so far, but I've barely scratched the surface. I did find that it didn't work with MyFaces 1.1, but I guess ICEfaces doesn't work with that?

                                    We'll see what happens when I add some meat to the test.

                                    Stan