1 2 Previous Next 20 Replies Latest reply on Feb 24, 2007 8:19 PM by sjmenden

    Any experience with SeamFaceletViewHandler?

    smokingapipe

      I was looking at:

      http://docs.jboss.com/seam/1.1GA/reference/en/html/elenhancements.html

      This looks super-cool. I could then have a table, and I could directly execute methods on entities from buttons in the table. I completely bypass needing a session bean for some operations if I can provide arguments to methods from within an expression. Cool!

      Does anyone have experience with this? I noticed from the docs:

      18.3.1. Incompatibility with JSP 2.1

      This extension is not currently compatible with JSP 2.1. So if you want to use this extension with JSF 1.2, you will need to use Facelets. The extension works correctly with JSP 2.0.


      I'm not sure what this means. I'm not using Facelets. I'm not sure if I'm using JSP 2.0 or 2.1. All I'm using is plain old JSF for my rendering. Will I be ok to try this Seam extension?

      Btw, I'm using JBoss 4.05 GA and Seam 1.1.0 GA.


        • 1. Re: Any experience with SeamFaceletViewHandler?
          smokingapipe

          I looked into it some more, and it looks like it would be substantial work to convert ALL my existing JSP pages to proper XML Faclets pages. Also it looks like it's non-trivial to even get Faclets working within JBoss; I kept on getting exceptions like:

          java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory


          which I have no idea how to solve.

          So, I think I need to wait for the cool new option of using method parameters directly within my JSF. That would be so cool to do, and would save me much time, so I'm looking forward to it.


          • 2. Re: Any experience with SeamFaceletViewHandler?

            If you are using JBoss 4, you are using JSP 2.0. JSP 2.1 is the Java EE 5 version, which is sadly not yet available on JBoss 4. I believe Tomcat 6 supports JSP 2.1, but you have to go to JBoss 5 for that. (Or maybe JBoss 4.2, though I've given up trying to figure out what exactly will or won't be in JBoss 4.2) If you are running Seam on another server, you may have JSP 2.1 at your disposal.



            • 3. Re: Any experience with SeamFaceletViewHandler?

              Oh, and Facelets is trivial to set up. Have a look at the examples. I would NEVER go back to plain JSPs unless forced to.

              • 4. Re: Any experience with SeamFaceletViewHandler?
                smokingapipe

                Ok, I'm running plain vanilla JBoss 4.0.5 with whatever Tomcat it comes with, meaning that I'm using JSP 2.0, so that shouldn't be a problem.

                "norman.richards@jboss.com" wrote:
                Oh, and Facelets is trivial to set up. Have a look at the examples. I would NEVER go back to plain JSPs unless forced to.


                Here's what I tried:

                I put the following in my faces-config.xml:

                <application>
                 <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
                 </application>
                


                which should just activate the Seam view handler, right? But then I get these exceptions:

                Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
                java.lang.NoClassDefFoundError: com/sun/facelets/FaceletViewHandler


                So I assume that if I put the right jars into my WEB-INF/lib, that would solve that exception, right? Any suggestions on which jars? Do I need to remove any jars from JBoss or do anything like that?

                Thanks


                • 5. Re: Any experience with SeamFaceletViewHandler?

                  Add the same jars that the example apps add. :)

                  I'm assuming the only thing you have to add is jsf-facelets.jar, but since I don't normally use JSP with seam, I may be forgetting something obvious. You should really just build one of the examples that uses facelets and compare.

                  • 6. Re: Any experience with SeamFaceletViewHandler?
                    smokingapipe

                    Ok, I'll try that. I'm now thinking that the problem is I don't have the Facelets Servlet installed in my web.xml. That would make sense; it's a load-on-startup servlet which probably does set up factories, etc.

                    But then I'm totally confused about URLs. Right now my files are .jsp files, but they are actually served by Seam, so the URLs are all .seam URLs. I notice in the Facelets examples they are all .xhtml files. What is the logic for getting these .xhtml files to be processed by both Seam and Facelets? I'm totally confused.

                    One good thing about changing them from .jsp to .xhtml is that NetBeans has a good built-in xhtml editor that will spot xhtml syntax errors, so I won't have to worry about that. I just have to worry about getting Seam and Faclets to operate on the same files, right?

                    • 7. Re: Any experience with SeamFaceletViewHandler?
                      smokingapipe

                      I'm trying to figure out how the example Facelet apps are working. The one I am looking at, Seampay, has NO jars at all. I don't see how this is even possible. Are you sure that Facelets is practical with Seam and JBoss? There doesn't seem to be much information about what is needed and I can't get past this "could not find Factory: javax.faces.context.FacesContextFactory". Any idea how to set that up?

                      • 8. Re: Any experience with SeamFaceletViewHandler?
                        smokingapipe

                         

                        "norman.richards@jboss.com" wrote:
                        Oh, and Facelets is trivial to set up. Have a look at the examples. I would NEVER go back to plain JSPs unless forced to.


                        It simply is not trivial. It is far from trivial. I have been working on this all evening. I can't get past this exception, even though that class is obviously in the jar file. Hmmmm.


                        • 9. Re: Any experience with SeamFaceletViewHandler?
                          smokingapipe

                          After some more changes I am now getting:

                          java.lang.IllegalArgumentException: Class org.jboss.seam.ui.facelet.SeamFaceletViewHandler is no javax.faces.application.ViewHandler
                          


                          In my entire experience with JBoss and Seam, about 40% of the project time has been spent working on config files and jar files. It seems like a powerful tool but getting it to actually work without throwing exceptions is almost half the battle.


                          • 10. Re: Any experience with SeamFaceletViewHandler?
                            smokingapipe

                            And I just looked at that error, and looked at the source code. In src/ui/org/jboss/seam/ui/facelet/SeamFaceletViewHandler.java, it says:

                            public class SeamFaceletViewHandler extends FaceletViewHandler


                            so SeamFaceletViewHandler most certainly is a FaceletViewHandler. There must be a bug in org.apache.myfaces.config.FacesConfigurator.getApplicationObject(FacesConfigurator.java:536) to be causing this, because the class is correct. Hmm, any ideas?


                            • 11. Re: Any experience with SeamFaceletViewHandler?
                              smokingapipe

                              Now I copied the myfaces jars from the facelets distribution, and I get:

                              00:59:18,186 ERROR [StartupServletContextListener] Error initializing ServletContext
                              javax.faces.FacesException: org.jboss.seam.jsf.SeamApplicationFactory
                               at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:587)
                               at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:460)
                               at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
                              .....
                              Caused by: java.lang.InstantiationException: org.jboss.seam.jsf.SeamApplicationFactory
                               at java.lang.Class.newInstance0(Class.java:340)
                               at java.lang.Class.newInstance(Class.java:308)
                               at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:585)
                              


                              which is different, but still the app can't run. Surely when someone was developing these packages, they must have gotten them to run somewhere? These things are on released versions, implying not just that they were built but they have been run?


                              • 12. Re: Any experience with SeamFaceletViewHandler?
                                smokingapipe

                                And now, after closely copying the seampay example, whenever I try to access a page with the .seam extension, I get:

                                01:32:04,519 ERROR [PhaseListenerManager] Exception in PhaseListener RESTORE_VIEW(1) afterPhase
                                java.lang.IllegalStateException: No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)
                                 at org.jboss.seam.contexts.PageContext.getPhaseId(PageContext.java:153)
                                


                                This shouldn't be so hard to get working.....


                                • 13. Re: Any experience with SeamFaceletViewHandler?
                                  smokingapipe

                                  Ok, I looked some more in the seam-pay application, and I found that its application.xml file references:

                                  <module>
                                   <ejb>jboss-seam-pay.jar</ejb>
                                   </module>
                                   <module>
                                   <java>jboss-seam.jar</java>
                                   </module>
                                   <module>
                                   <java>el-api.jar</java>
                                   </module>
                                   <module>
                                   <java>el-ri.jar</java>
                                   </module>
                                  


                                  Are these needed? Should I put those jars (specifically el-*.jar) in my .ear file like seam-pay does? This may be the missing ingredient here.


                                  • 14. Re: Any experience with SeamFaceletViewHandler?
                                    spambob

                                    Without knowing more about your configuration files I can't help you except saying they might be flawed (surprise ?!) - i.e. the org.jboss.seam.ui.facelet.SeamFaceletViewHandler is configured in my web.xml _not_ in faces-config.xml.

                                    If I were you I would use seam-gen (as described at http://docs.jboss.com/seam/1.1GA/reference/en/html/gettingstarted.html). This generates you a _working_ seam application with facelets. From then on you can play with it and transfer the config in your app.

                                    Regarding the jars: the el-api & el-ri are in my ear root (I'm not sure if WEB-INF/lib is fine too) and jsf-facelets.jar is in /WEB-INF/lib.

                                    Last but not least note that you must _not_ have jars containing the same class in your apps classpath and the servers classpath. Further the configuration is different when you use ajax4jsf - leave that out until you have facelets working.
                                    Another idea would be to delete the servers working directories (server/default/log, -tmp, -work).

                                    Hope this helps :)

                                    1 2 Previous Next