| Issue 123: | Add Portlet Support | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Ok, here is some preliminary support for portlets, with an even more preliminary example (both with regular Portlet API and AJAX enhanced) The example is using the retro build from trunk and targets a Java 1.4/Servlet 2.3/Portlet 1.0 environment (sorry, that's what I use). Optimally, this would run in a Java 1.5/Servlet 2.4/Portlet 2.0 environment, in which case the example would be written slightly differently because the AJAX/export logic could be built right into the portlet controller. As it happens, Portlet 1.0 does not allow the controller to modify headers or bypass the portal page markup for exports/AJAX requests. PortletRequestWebContext is compiled against portlet-api-2.0.jar, but should work fine in a portlet 1.0. I think that support for portlet 1.0 should be maintained (at least minimal support) for two reasons: 1) Portlet 2.0 was only released this month, and most containers do not yet implement it 2) I use Portlet 1.0 ;) I added a few methods to TableFacadeFactory for creating a table facade from a portlet request, a spring table facade from a portlet request, and a table facade from a WebContext. Also added PortletRequestSpringWebContext and a generic WebContextWrapper. The extra methods on TableFacadeFactory necessitated small syntax changes in the tags. A portlet-specific tag does not need to be added I think, since the JSP API works the same in portlets as it does in servlets. In the future I can adapt the example to align more closely with the other JMesa examples. An important aspect of using JMesa in a portlet is to make sure that you transfer the appropriate action parameters to the render phase using ActionResponse.setRenderParameter(). See Table.updateState() in the example. If you do not do this, the table will not work. Attachments to follow.
Jul 22, 2008
Here is an example WAR file:
Jul 22, 2008
Everything looks really good! I want to look things over a little more before checking things in but I do not have time tonight. Thats great that you even included an example war file! I have not worked with portlets before. What is the url I would use to display the table?
Jul 23, 2008
I was able to look over things before going to work today :). Really nice job! I like how you improved the TableFacadeFactory. After seeing what you did I was able to add onto it myself and then refactor the spring and struts tags to just use the factory now. Everything is checked in now on the trunk. You will notice that I changed the names of your portlet methods in the factory. The reason is because the compiler would not compile my web project unless I had the portlet jar file in the path. I guess that makes sense because it is trying to resolve between two methods that only differ by the arguments. It gets to the PortletRequest object and doesn't know about it. Being explicit about the methods of course resolves it. I also didn't know that you could change the return variable on interface methods. I thought that that was just a feature of overriding class methods. I do it alot in the API but it was great that I could do it on the WebContext classes as well. public HttpServletRequest getBackingObject() {}
Jul 23, 2008
> Thats great that you even included an example war file! I have not worked with > portlets before. What is the url I would use to display the table? Right now you would need to have a portlet container to run the project... Apache Pluto (http://portals.apache.org/pluto) is the reference implementation and has a version bundled with Tomcat that you could try. There's a small learning curve involved with properly assembling web.xml to install the webapp though. As an alternative, if I have some time, I can modify the jmesaWeb build file to include a 'run' target that could start up the examples using the Jetty ant plugin... additionally, I can include pluto.war in the setup so that the portlet examples can be run side by side with the servlet examples.
Jul 23, 2008
I'd vote for whatever is easiest to get the example war up and running. I don't mind at all having different example war files but there needs to be an easy way to get them up and running. That could also just mean documenting the steps to getting it running. For instance first download pluto, then..., etc. It would also be nice to have an index.jsp file with a javascript document.location link to forward to the table automatically. The Grails plugin has its own example war file right now too. I think people are just happy to have something to run and test.
Jul 23, 2008
I have pluto up and running now.... What else do I need on the URL to access the table? http://localhost:8080/JMesaTest/
Jul 24, 2008
http://localhost:8080/pluto/portal.. then find the admin portlet and deploy the JMesaTest.war file. Finally, pick a page on which to put the portlet and navigate to that page. Which version of Pluto are you using?
Jul 24, 2008
Once I deploy the war file should it show up as a portlet application in the admin screen? I read the documentation on the site for awhile and tried a few things but no luck. What your saying makes sense but I think its supposed to just appear after restarting pluto up?
Jul 25, 2008
I thought that the most recent version of Pluto had integrated the assembly step into the deployment process... portlet apps are really just web apps with some extra semantics, and Pluto handles the portlet lifecycle by creating a wrapper servlet for each portlet defined in portlet.xml. In order to this do though, and extra build step has to be taken to add the wrapper servlets in the web.xml file. I'll have something more usable for you by the end of the day.
Jul 25, 2008
Ok, I think this will be the easiest way to get up and running. I'm attaching 3 files: 1) portlet-examples.patch - a patch against jmesaWeb that includes an AJAX example and regular portlet example. Also, updates ivy.xml with spring-portlet.jar. Finally, there was an @Override annotation that was throwing an error in Eclipse when set to Java 5 compliance settings, but it worked under Java 6 (I think, because it is overriding an interfacing method, rather than a superclass method). I just took out the annotation. 2) add-to-repository.zip - contains Spring Portlet MVC version 2.0.2 to match the version used in jmesaWeb 3) server.zip - A trimmed down Pluto/Jetty stack for running the examples. Just unzip this in your projects directory (the 'server' directory should be at the same level as 'jmesaWeb' and 'repository'). `cd server` and `ant run-examples` (or just `ant`) and point your browser at http://localhost:8080/ Clicking on the pluto context will take you to the portal and clicking on the jmesa context will take you to the servlet examples. I modified jmesaWeb/build.groovy with an extra task called run() which builds the example project and starts the server with it. The only caveat is that you need to remove jsp-*.jar and servlet-*.jar from $GROOVY_HOME/lib in order to avoid classpath issues. Starting the server from the ant build does not suffer from this problem. I have the portal configured with both the regular portlet example and the AJAX example on one page. Because of the javascript namespace dilemma that I presented in the group, the regular portlet example does not work when both portlets and rendered on the same page. Minimizing the AJAX portlet or Maximizing the regular portlet solves this problem. I think this is a good setup because the Jetty ant task will automatically reload the web app if you compile any classes, so its really easy to try out different things with the examples. It would be really nice if it could detect (I know there's a way) when jmesa-snapshot.jar is rebuilt so that the changes could be reflected in the examples right away as well.
Jul 25, 2008
(No comment was entered for this change.)
Jul 25, 2008
(No comment was entered for this change.)
Jul 25, 2008
Jeff, I think I have to send the server file to you via email...
Jul 26, 2008
Once again you did some amazing work! I was able to apply the patches and get the portal running on the first try :). I am going to check in the server folder (renamed to portal) into subversion and then write these directions up on the wiki. I'll post a link when I get that done. Thanks again!
Jul 26, 2008
Here is the link to the portal writeup. https://code.google.com/p/jmesa/wiki/PortalExample
Status:
Fixed
|
15.3 KB View Download