Custom Portlet mode implementation

JSR 168 Portlet specification defines standard portlet mode as View, Edit and Help and custom portlet mode as config mode and edit_defaults mode.
Implementation of standard portlet modes are straight forward but custom mode implementation requires additional coding and configuration.

Here i will explain about config mode configuration and implementation, in the same way you can implement edit_defaults mode.

Config Mode configuration
To enable Config mode functionality, define following custom portlet mode tag entry in portlet.xml

custom portlet mode entry should appear just after end of portlet tag.

Config Mode implementation
Now, next step would be to override doDispatch method.
In doDispatch method, we will first identify the windowState and if it not minimized then we will find portlet mode from request and based on result will call doCofigure method.
here doConfigure method implementation needs to be done.

code snippet:-
First inside your portlet class define a variable for config mode.
private static final PortletMode CUSTOM_CONFIG_MODE = new PortletMode("config");

protected final void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException {
try {
WindowState state = request.getWindowState();
if (!state.equals(WindowState.MINIMIZED)) {
PortletMode mode = request.getPortletMode();
if (mode.equals(CUSTOM_CONFIG_MODE)) {
doConfigure(request, response);
super.doDispatch(request, response);
} catch (PortletException e) {
} catch (IOException e) {

public void doConfigure(RenderRequest request, RenderResponse response) throws PortletException, IOException {

No comments: