concept portlet.xml in category java

appears as: portlet.xml
Portlets in Action

This is an excerpt from Manning's book Portlets in Action.

The <portlet-app> element is the root element of portlet.xml, and a portlet declaration is enclosed within the <portlet> subelement of the <portlet-app> element. In most cases, a single portlet.xml file contains multiple portlet declarations (because a portlet application usually consists of more than one portlet), and all the portlets defined in a single portlet.xml file form part of a single portlet application.

BookCatalogPrefsValidator makes use of the BookService class to invoke the isUniqueISBN method. If you’re using the Spring Portlet MVC framework, a class like BookService is configured in the portlet application context XML file with a dependency on a data access object (DAO). In such cases, you can configure the preferences validator class in the portlet application context XML file (instead of portlet.xml), autowire dependencies, and programmatically validate preferences by invoking the validate method. Alternatively, you can use Spring’s @Configurable annotation along with load- or compile-time weaving to autowire dependencies into the preferences validator instance that is not created by Spring.

Listing 10.15. Portlet preferences defined in portlet.xml