• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How should Portlets fit in MVC?

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see Portlets should act as Controller (just like Servlets) and JSPs act as View. So no HTML markup should be presented in Portlets' doView, doHelp, or
doEdit. Any comments?
 
Author
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,

long comment:

The portlet markup must be created in the render phase of a portlet's life cycle, which is represented by the render method of interface javax.portlet.Portlet. doView, doEdit etc. are methods of GenericPortlet, which is an adapter class of the Portlet interface. The render method dispatches to them.
It is not forbidden (and quite common for simple examples) to produce HTML markup during the render call, e.g. in the doView method. JSP is one option to create the markup (you may choose other technologies like tapestry or JSF) during the render call. In this case, your markup is in the JSP file, and the render (or doView) call includes its output with a PortletRequestDipatcher. The data presented by the JSP (Java objects) is created before the include call in the render phase or during processAction (two options here).

short comment:
we do it just as you have described it

Greetings, Stefan
 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stefan, I saw you are a IBM certified Portal developer so am asking another
question:

How should Struts fit in Portal/Portlet? Which component is the Controller?
 
Stefan Zoerner
Author
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,

Struts and most other web frameworks do not exactly fit to the portlet paradigm, because in JSR 168 we have two types of requests (render, action), in the Servlet API (and Struts etc.) there is only one. But the basic ideas are comparable.

The portlet class itself acts as a controller (just like the ActionServlet in traditional Struts). You may program actions/commands as pojos and call them from the lifecycle methods of the Portlet class. Not that both render() and processAction() may perform a command, it depends on your situation which one is right. After that you dispatch to a JSP or use another template techology to create the markup.

You can create your own framework for that, but some already exist. There are also bridges available for Struts, but they hide the portlet paradigm -- I would only use them to cahnge an existing Struts app into a portlet, if you do not have the time to do it right ;-)

Links:

MVCPortlet
Spring Portlet MVC
Struts Bridge (Apache Portals)
[ January 05, 2006: Message edited by: Stefan Zoerner ]
 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stefan,

Thanks for your comments on Struts and Portlets.

I was told that it is very easy to convert a Struts application to
Portal/Portlet application. It is not true from what I read:

All the Action classes and JSPs need changed. If alots of JavaScripts
are used in JSPs, there will be more problems ....

A question:
What is "service portlet" and "business process portlet"? They are not in
JSR168. I guess these portlets do not create any HTML markups. Why do we need them instead of EJB or Web services?
 
Stefan Zoerner
Author
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

"business process portlet" seems to be a vendor specific term (IBM, WebSphere Portal in conjunction with WebSphere Process Server). Check out this article. But these portlets will generate markup (HTML, WML, ...) just as other portlets do. Just a web (portal) based frontend for human interactions which are controlled by a workflow engine.

WebSphere Portal supports "portlet services", but I have no idea what a "service portlet" is. Where did you find this term?

Greetings,
Stefan
[ January 09, 2006: Message edited by: Stefan Zoerner ]
 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. It should be called "portlet service".
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

For MVC Portlet Developement , u can refere the following article

http://today.java.net/pub/a/today/2005/03/08/mvcportlet.html

nJoy
~Neeraj Sidhaye
try_catch_finally@yahoo.com
http://www.extremeportal.blog.co.uk
 
Stefan Zoerner
Author
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,

portlet services are vendor specific (IBM WebSphere Portal). Learn more about them in chapter 19 of this redbook (complete content available online in PDF and HTML).

The most useful predefined portlet service from my point of view is "Credential Vault Service", which allows you to access the crendential vault of portal server.

Greetings, Stefan
 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stefan,

I'm reading the redbook. The "portlet service" is more like a Proxy on the client side to the backend service. The call from portlet to portlet services are local in the same Portal server. So it can not replace RMI or EJB.

Portlet service is a shared service by other portlets. But, like all the lib, it can be done with a simple jar file.

Why does IBM require us to register it?
 
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic