Previous Topic: Call the Request Widget Using Menu OptionsNext Topic: Use the Status Widget and Other Widgets to Let Users Access Requests


Call the Request Widget Using Source Code

In Liferay, you can call the Request widget by creating the portlet and specifying the source code. Review the following steps for producing the earlier Request widget example. Follow them as a model to configure the display and behavior of the Request widget in your implementation.

Follow these steps:

  1. On the portal page, perform these actions to create the portlet:
    1. Click Add, Web Content Display.
    2. Click the plus icon (Add, Web Content).

      The New Web Content window appears.

    3. Specify the required fields and close the window.

    The new portlet gets added to Liferay.

  2. Click Edit Controls at the top of the page.
  3. Mouse-over the portlet, and click the pencil (Edit Web Content) icon.

    The portlet Settings appears.

  4. In the Content window, click Source.

    The Source container opens for editing.

  5. Review the following source and key parameters for the earlier Request widget example. Use them as a model to specify your source.
  6. Perform the following actions:

Source and Key Parameters

The source for the Request widget example follows:

<script type="text/javascript" src="http://hostname:portnumber/usm/gwt/fdRenderer/fdRenderer.nocache.js"></script>
<script type="text/javascript" src="http://hostname:portnumber/usm/explorer/scripts/request.widget.js"></script> 
<script> CA_Catalog.buildWidget({type: 'request', renderTo: 'targetDiv', login credentials, businessUnit:’London222", rootId: -1, linkColor: 'inherit', borderColor: 'darkGreen'}); </script>
<div align="left" id="targetDiv" style="margin-bottom: 10px;">
	&nbsp;</div>

The first line references the form renderer required for the Request widget.

The second line references the JavaScript file for the Request widget.

The third line specifies the JavaScript with configuration parameters for the Request widget.

Note: Separate parameters with a comma, but do not specify a comma after the last parameter.

The fourth line specifies the DOM element in which the Request widget is rendered.

Key parameters and explanations follow for the CA_Catalog.buildWidget function call in the Request widget example.

login credentials

We recommend single-sign-on for widgets. However, if you require login credentials for this widget, specify them in this function call. Use the following format:

username: 'username', password: 'password'
type:"request"

Specifies that the widget is a Request widget.

renderTo:"targetDiv"

Specifies that the widget is rendered into the DOM element whose ID is targetDiv.

businessUnit:"London222"

Specifies the business unit that catalog users can access while utilizing this Request widget. Users can request services in all folders in this business unit.

For example, if you specify the root business unit, users can request services from all folders in all business units, including the root business unit. Conversely, if you specify the lowest level business unit, users can request services from folders in that business unit only.

If you do not specify a value, the Catalog system uses the default business unit of the user accessing the widget.

rootId:–1

Specifies that when the Request widget opens initially, it displays nothing.

When the user clicks a service in the Browse widget, the Request widget displays that service.

Note: If you specify the name of a service in this parameter, the service must exist in a business unit that the user can access, as explained in the businessUnit parameter.