Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than one portlets in a single war file

 
Dorothy Taylor
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

Can anyone please tell me when do we need to package more than one portlets in the same war file?

Thanks in advance
 
Hemant Sharma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More than one portlets are packaged in the same war
- When we have related portlets which need to share the same context which
contains all resources such as images, properties files and classes.
- Theres a need to share resources and send messages among the portlets to communicate events.
 
Dorothy Taylor
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what if two portlets have the same JSP or the formbean? In this case also do they need to be in the same war file
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if two portlets have the same JSP, they need to be in the same war, that's for sure.

A single portlet application is delivered as a war file, but that application may have many portlets within it. An accounting application might have one portlet that allows you to file, one that allows you to find tax information, one that allows you to manage receipts, and anothet that allows you to file income. All might be different portlets, but packaged together in a common war file.

Many tutorials show only one portlet per war, but when you get deep into portlet programming, many portlets per war becomes the norm.

-Cameron McKenzie
 
Jonas X. Yuan
author
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

here is an example - one war, five portlets. - Spring MVC portlets in Liferay

1. Download plugins-sdk with Spring MVC portlets from http://liferay.cignex.com/sesame/plugins-sdk.zip
2. Unzip plugins-sdk.zip; Find build.Jonas.properties
3. Rename build.Jonas.properties into build.${username}.properties.
4. Update entry (app.server.dir) in build.${username}.properties. Let it point to Liferay Tomcat directory. For example: app.server.dir=C:/training/tomcat.
5. Drop �build.xml� at /portlets to Ant view.
6. Development �
7. Run Deploy at Ant view if you are ready.
8. Test portlets at Liferay runtime �
 
Dorothy Taylor
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cameron Wallace McKenzie:
Yes, if two portlets have the same JSP, they need to be in the same war, that's for sure.

A single portlet application is delivered as a war file, but that application may have many portlets within it. An accounting application might have one portlet that allows you to file, one that allows you to find tax information, one that allows you to manage receipts, and anothet that allows you to file income. All might be different portlets, but packaged together in a common war file.

Many tutorials show only one portlet per war, but when you get deep into portlet programming, many portlets per war becomes the norm.

-Cameron McKenzie



In this example, why do we need to package all these accounting portlets in a single war? Why can they not be independent portlets?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I always say, there are no right answers, only wrong answers. As long as we don't get a wrong answer, we are okay.

A war should contain a set of common, related components - just like in a large Servlet & JSP application. If you have a bunch of HR or Accounting portlets, it makes sense to deploy them in a single war. Furthermore, being in a single war makes it possible to have then share information through the PortletSession's application scope.

If you have IBM portal, look at all the portlets IBM provides that are in a common, single, war. I think Lotus Notes has like 10 portles that provide Notes functionality, all of which are sensibly packaged in a single war. After all, it' be annoying to have to deploy 10 war files to get 10 commonly related portlets that provide Notes functionality.

-Cameron McKenzie
 
Dorothy Taylor
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, understood that, but just one more small query...as you said that similar portlets can be grouped as a single war. Now, how should the implementation be for the action classes and jsp's of such portlets? I mean even when the portlets are packaged in one war, should they have independent action classes and jsp's unless they are absolutely alike, or should we check in the SAME action class if portlet "A" triggers this action do something and if portlet "B" triggers then do something else
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though they might be packaged together, you can still develop them as though they were independent portlets.

It becomes simliar to a Servlet/JSP application in that regard. If you have a LoginServlet that forwards to a successfullogin.jsp page, that Servlet and JSP page doesn't need any knowlege of a Servlet named GetAccounBalance or a JSP named displaybalance.jsp.

They may be in the same war file, and even the same folders, but they need not interact with each other. In that regards, the portlets become similar to Servlet and JSPs packaged in a common war.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic