1 2 Previous Next 18 Replies Latest reply on Jun 5, 2006 8:19 PM by Danijel Jevtic

    Seam JSR168 Portlet and EJB3 and Facelets

    Evan Zeng Newbie

      Is it possible to develop jsr168 portlet with Seam using EJB3 and Facelets?

        • 1. Re: Seam JSR168 Portlet and EJB3 and Facelets
          Gavin King Master

          We have an example of Seam/JSP in JBoss Portal in CVS. However, we were not able to make facelets work in the portal (which does not mean it is not possible).

          • 2. Re: Seam JSR168 Portlet and EJB3 and Facelets
            Colin Toal Newbie

            I have JBoss 4.0.4RC1 w/EJB3, Seam, Portal 2.4, and Facelets (with the MyFaces GenericPortlet) working together just fine - with jBPM doing Pageflow.

            So yes - it is absolutely possible.

            • 3. Re: Seam JSR168 Portlet and EJB3 and Facelets
              Evan Zeng Newbie

              Could you give me an example?

              • 4. Re: Seam JSR168 Portlet and EJB3 and Facelets
                Anthony W. Marino Newbie

                Hi Colin -
                I, too, am interested if you are willing to offer an example.

                Thanks,
                Anthony

                • 5. Re: Seam JSR168 Portlet and EJB3 and Facelets
                  Colin Toal Newbie

                  Most of the work in getting these things together is in packaging everything together with the right descriptors.

                  I will prepare an example as soon as I have a chance tonight, and I will post it for download either on PortletSwap or on my own web server.

                  • 6. Re: Seam JSR168 Portlet and EJB3 and Facelets
                    Gavin King Master

                    That would be great! :-)

                    • 7. Re: Seam JSR168 Portlet and EJB3 and Facelets
                      Stijn de Witt Newbie

                      I too would be very interested in seeing an example of this. Is there any news on this topic? Could you post an url if it's at your website?

                      Thanks,

                      -Stijn

                      • 8. Re: Seam JSR168 Portlet and EJB3 and Facelets
                        Colin Toal Newbie

                        I've prepared an Eclipse project, with JBoss IDE Packaging configuration for an EAR file that deploys a portlet instance of the "Guess a Number" sample application from the jboss seam source.

                        It works with the following configuration:

                        JBoss AS 4.0.4RC1 from source in JDK 1.5
                        JBoss Portal 2.4 from source ( it might work with 2.2.x also )
                        JBoss SEAM latest from source
                        JBoss EJB3 implementation (part of AS 4.0.4RC1)
                        JBoss jBPM as packaged in SEAM (jBPM 3.1.1)
                        Facelets and MyFaces as deployed in Portal 2.4 for administration.

                        The key differences between this and the standard Guess a Number sample application are in the following areas:

                        1) View pages

                        I've re-tagged the view pages as Facelet based view definitions instead of JSP based view definitions.

                        2) Bean implementation

                        I've changed the numberGuess class to be EJB3 Bean based. It is packaged in a sample-portlet-bean.jar for demonstration purposes.

                        3) Packaging configuration

                        All of the standard JBoss and JSR 168 portlet descriptors are included in the packaging.

                        It is packaged as an EAR file - with a single bean JAR, and and a single web app WAR file. The jboss-seam.jar file is packaged in the EAR file, along with the jBPM-3.1.1.jar file and both are classpath'ed in the MANIFEST.MF that is packaged in the WAR and JAR files.

                        The full packaging-build.xml for JBoss IDE is included in the Eclipse project. You will need to adjust the paths for your local install of Seam and also the library references will need to be adjusted for your local JBoss install.

                        4) Changes to faces-config.xml

                        The following faces-config.xml changes are necessary:

                         <!-- Facelet Portlet View Handler -->
                         <!-- Critical for Facelet Portal Support -->
                         <application>
                         <view-handler>
                         com.sun.facelets.FaceletPortletViewHandler
                         </view-handler>
                         </application>
                        
                         <!-- JSF Phase Listener for SEAM based Portlets -->
                         <!-- Install's Seam Contextual compoent support for Portlet -->
                         <!-- Critical difference from standard Seam Application -->
                         <!-- deployment. -->
                         <lifecycle>
                         <phase-listener>
                         org.jboss.seam.jsf.SeamPortletPhaseListener
                         </phase-listener>
                         </lifecycle>
                        


                        And the following changes were made in web.xml to allow for both the switch to an EJB3 based logic layer :

                        <!-- JNDI name pattern for EJB3 (change for other servers) -->
                        <context-param>
                         <param-name>
                         org.jboss.seam.core.init.jndiPattern
                         </param-name>
                         <param-value>
                         sample-portlet/#{ejbName}/local
                         </param-value>
                        </context-param>
                        


                        And the following change - commenting out the the StartupServletContextListener - is the only other difference from a standard Seam web.xml configuration.

                        <!-- MyFaces Context Listener -
                         Commented out because Portal
                         Loads this Context Listener
                        <listener>
                         <listener-class>
                         org.apache.myfaces.webapp.StartupServletContextListener
                         </listener-class>
                        </listener>-->
                        


                        I have posted the project to box.net for now (I am out of town, and can't get at my machine to post it on my own server).

                        http://www.box.net/public/5stdsud5f3

                        If there is a JBoss.org location for something like this, I can also post it there. Outside of that - if you can't access it from box.net - let me know and I'll find another way to get it to you.

                        Thanks


                        • 9. Re: Seam JSR168 Portlet and EJB3 and Facelets
                          Evan Zeng Newbie

                          Thank you, Colin!

                          • 10. Re: Seam JSR168 Portlet and EJB3 and Facelets
                            Gavin King Master

                            I would love it if you could get this information up on the wiki...

                            • 11. Re: Seam JSR168 Portlet and EJB3 and Facelets
                              Per Wiklander Newbie

                              I'm running into some mind mazes when thinking about all this portal stuff :-)

                              In a normal Seam app I would deploy all EJB .jars in the same .ear as the .war. As I understand no other apps outside of that .ear would be able to use those Seam components.

                              When using a portal structure I would first deploy a portal and then later on hot deploy portlets to that portal while it is running. Each of my protlets would probably have their own Seam components that no other protlets would need but at the same time all of my portlets would want to access global things, like the currently logged in user and settings components.

                              Is this possible? If so, how?
                              Have I just totally missed out on how all this works together?

                              • 12. Re: Seam JSR168 Portlet and EJB3 and Facelets
                                Gavin King Master

                                The portal spec does not currently define any standard way to do inter-portlet-communication. But most portal containers - including JBoss Portal - have some extension to make that possible.

                                • 13. Re: Seam JSR168 Portlet and EJB3 and Facelets
                                  Per Wiklander Newbie

                                  I'm not sure if I understand your answer, or if you understood my question (which might have been a little blurry). The thing I'm trying to sort out is that Seam components (EJB SFSBs) deployed in one .ear can not be used by things deployed in other .ears, right?

                                  • 14. Re: Seam JSR168 Portlet and EJB3 and Facelets
                                    Gavin King Master

                                    EJB Session beans can be accessed from outside the EAR via JNDI.

                                    But Seam components are scoped to the EAR because the component registry is kept in the web application context.

                                    1 2 Previous Next