SAS 9.1.3 Integration Technologies » SAS Web Infrastructure Kit: Developer's Guide


Developing Custom Portlets
Development Steps
Creating a Deployment Descriptor
Creating Display Resources Files
Developing the Presentation JSP Page
Creating Action Classes
Implementing Portlet Help
Creating a PAR File
Use Cases
Simple Display Portlet
Localized Portlet
Portlet Template (Editable Portlet)
Remote Portlet
Tips and Best Practices
Using the Portlet API
Sample Portlets
Localized Display Portlet (Welcome)
Interactive Form Portlet (FormExample)
Portlet Template, or Editable Portlet (DisplayURL)
Web Application (HelloUserWikExample)
Remote Portlet (HelloUserRemote
Portlet
Sample: Portlet Template, or Editable Portlet (DisplayURL)

Editor Action

The DisplayURL portlet's EditorAction class is invoked when a user clicks the portlet's Edit icon. The source code follows.


/**Copyright (c) 2003 by SAS Institute Inc., Cary, NC 27513.
 * All Rights Reserved.
 */
package com.sas.portal.portlets.displayurl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//import com.sas.portal.Logger;
import com.sas.portal.portlet.PortletContext;
import com.sas.portal.portlet.NavigationUtil;


/**
 * Action class that presents the edit page. It sets up the edit model
 * then instructs the portlet container to present the edit page.
 */
public final class EditorAction extends BaseAction
{
//    private final String _loggingContext = this.getClass().getName();

    /**
     * Service the portlet request.
     *
     * @param request the HttpServletRequest
     * @param response the HttpServeltResponse
     * @param context the PortletContext
     * @return the URL to call
     */
    public String service(HttpServletRequest request,
                          HttpServletResponse response,
                          PortletContext context) throws Exception
    {
        super.service(request, response, context);

        //create the URLs for the OK and Cancel buttons.
        String url;

        url = NavigationUtil.buildBaseURL(context, request,
           "ok");
        context.setAttribute(Initializer.EDIT_OK_URL_KEY, url);

        url = NavigationUtil.buildBaseURL(context, request,
           "cancel");
        context.setAttribute(Initializer.EDIT_CANCEL_URL_KEY, url);

        // the following call resets the mode back to display for the
        // next call
        context.resetMode();

        return (String) context.getAttribute("edit-page");
    }
}