-
15. Re: Seam JSR168 Portlet and EJB3 and Facelets
perwik May 24, 2006 4:54 PM (in response to evanzeng)That's what I thought, and that's where I get confused. Is a Portal one web application or is it supposed to be seen as a bunch of different applications / portlets, which in that case can't share Seam components?
-
16. Re: Seam JSR168 Portlet and EJB3 and Facelets
colintoal May 24, 2006 9:35 PM (in response to evanzeng)Okay - I think I get your question - but let me reiterate in case:
The current portlet specification knows nothing of the concept of Seam Contexts - so how does a Portlet Context interact with a Seam Context.
I think the next portlet specification (JSR 286 ? 268 ? I always forget the number) and the forthcoming Web Bean specification should attempt to address the following scenarios:
1. Multiple portlets and Seam components deployed in a single EAR file
Are Seam component instances shared across portlet instances and portlet classes when all are deployed in the same application ?
2. Multiple portlets and seam components deployed in separate EAR files
Are Seam component instances in EAR A accessible to Portlet classes deployed in EAR B ?
Test 1:
The Seam Guess a Number portlet from this thread with a second portlet class that allows the user to 'Set' the secret number.
Test 2:
Same as Test 1 - with the second 'Set the Number' portlet deployed in a separate EAR file.
Assuming the result of these tests show that Seam components can be shared across portlets in JBoss Portal (would be a neat 'feature' - and would make all of the folks like me out here playing with JB Portal and Seam together happy) - there are no guarantees that it will work in Jetspeed or other JSR168 containers since JSR168 has no knowledge of 'Contextual components'.
I don't know how much of Seam Context is based on HTTPSession, and what layer it 'insinuates' itself in (overtop of JBoss Portal PortletSession, underneath of JBoss Portal PortletSession -- interleaved with PortletSession on some kind of lucky namespace coincidence ? - I suppose I could read the code, but the tests above will likely take me as long since I'm better at writing than reading.)
I can take some time this weekend to frame up those tests - but I suspect Gavin or others here might already know whether either of these scenarios work.
Also - just catching up on the thread - did anyone else get the Seam Portlet example I posted to work ? Is it Wiki worthy ? Is there changes I should make before I make a formal contribution to the Wiki ?
Thanks for reading -
17. Re: Seam JSR168 Portlet and EJB3 and Facelets
colintoal May 24, 2006 9:44 PM (in response to evanzeng)Reading Gavin's last post - I suspect the test will be half worthwhile and half not. There is hope for the first test -- all the portlets and Seam components in the Same EAR (component registry belongs to the Web Application) - but it still needs to be confirmed with a test. If it does work, I think it should be part of the Portlet support of the eb Bean specification. :)
I'm certain the second scenario will not work at all. It won't work with two WARs or two EARs (with good reason - namespace collisions on Component names would suck *ahem* be unfortunate) so why should it work on Portlets ? -
18. Re: Seam JSR168 Portlet and EJB3 and Facelets
dajevtic Jun 5, 2006 8:19 PM (in response to evanzeng)Hi. Thank you for the example. One small interesting thing might be to add to the wiki, what if one application wants to use both, jsp and facelets. I tried out a lot of different configurations, but none really got both working.
I decided to create a view handler, which checks if a facelet or a jsp should be rendered and delegate the render method to the corresponding view handler. If anyone is interested to try, feel free:public class JspAndFaceletViewHandler extends FaceletPortletViewHandler { private static final Log log = LogFactory.getLog(JspAndFaceletViewHandler.class); private SeamViewHandler seamViewHandler = null; private static final String FaceletSuffixConfigParameter = "javax.faces.DEFAULT_SUFFIX"; private String faceletSuffix = null; /** * @param arg0 */ public JspAndFaceletViewHandler(ViewHandler arg0) { super(arg0); seamViewHandler = new SeamViewHandler(arg0); } /* (non-Javadoc) * @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot) */ public void renderView(FacesContext arg0, UIViewRoot arg1) throws IOException, FacesException { if ((faceletSuffix != null) && (arg1.getViewId().endsWith(faceletSuffix))) { super.renderView(arg0, arg1); } else { seamViewHandler.renderView(arg0, arg1); } } @Override public UIViewRoot createView(FacesContext arg0, String arg1) { if (faceletSuffix == null) { faceletSuffix = arg0.getExternalContext().getInitParameter(FaceletSuffixConfigParameter); } if ((faceletSuffix != null) && (arg1.endsWith(faceletSuffix))) { return super.createView(arg0, arg1); } else { return seamViewHandler.createView(arg0, arg1); } } }