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: Interactive Form Portlet (FormExample)

Step 5: Create the JavaBean

The FormExample portlet was developed using a JavaBean called ExampleBean.java. This JavaBean places values in the PortletContext object so that the values are available to the JSP page.

The HttpServletRequest or HttpSession object could be used for this purpose. However, the PortletContext object is unique to the portlet and is not shared with other processes. Therefore, using it avoids collisions that could cause attribute values to be overwritten.

The source code for ExampleBean.java follows.


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

public final class ExampleBean {

/**Sets the user's input to this property. If input
 * is null, it will be changed to "" so that getUserInput()
 * never returns null.
 *
 * @param input
 */
public void setUserInput(String input) {
	if (input == null) {
		input = "";
	}
	this.input = input;
}

/**Returns the user's input or "".
 *
 * @return String
 */
public String getUserInput() {
	return input;
}

private String input = "";
}