concept mvcportlet in category liferay

appears as: MVCPortlet, MVCPortlet
Liferay in Action: The Official Guide to Liferay Portal Development

This is an excerpt from Manning's book Liferay in Action: The Official Guide to Liferay Portal Development.

This defines what Java class implements the portlet. By default, projects are generated to use Liferay’s MVCPortlet, which we’ll get to later. It has certain benefits for the experienced developer, but it also abstracts much of the portlet life cycle from you, which you don’t want to do just yet. You’ll implement your own portlet class the way the portlet specification recommends so you can get familiar with the Portlet API first. When you understand the basic Portlet API, you’ll be free later to move past it to MVCPortlet and other frameworks if you wish.

With that in mind, what in the world is Liferay thinking by having its own MVC framework? The answer to this question becomes apparent when you see the framework. Many of the MVC frameworks that are available can be heavy, with somewhat of a learning curve. They have configuration files that point to various parts of the application, and these files need to be kept in sync with the Java code they point to. Liferay’s MVC doesn’t have any of that. It’s much simpler to use than the other frameworks: there’s no configuration file like struts-config.xml or faces-config.xml to worry about. And it’s a simple extension of the GenericPortlet class you’ve already seen. For that reason, I like to use it. But if you’re still balking at the idea of another MVC framework, try thinking of it this way: you’re getting into Liferay now, so you might as well become familiar with MVCPortlet, because if you need to look at any of Liferay’s portlets, you’ll see it anyway. And you may find that you like it once you start using it.

Liferay has subclassed GenericPortlet to provide functionality that makes it easy to create MVC applications using portlets. This subclass is called MVCPortlet, and it enhances the way portlets handle actions and page management. All of Liferay’s portlet plugins are based on MVCPortlet instead of GenericPortlet, because it’s a much better option.

What’s different? Well, MVCPortlet is a lot easier to use. You won’t have to worry about page management anymore; you get it for free. Liferay’s MVCPortlet provides a simple means for page management. If you want to determine what JSP to display, all you need to do is point a render parameter called jspPage to the location of the JSP, and that’s the page that will be displayed to the user. This functionality does several things for you: