Previous Topic: Call the Status Widget Using Menu OptionsNext Topic: Call the Edit Request Widget Using Menu Options


Call the Status Widget Using Source Code

In Liferay, you can call the Status widget by creating the portlet and specifying the source code. Review the following steps for producing the earlier Status widget example. Follow them as a model to configure the display and behavior of the Status 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 Status widget example. Use them as a model to specify your source.
  6. Perform the following actions:

Source and Key Parameters

The source for the Status widget example follows:

<script type="text/javascript" src="http://hostname:portnumber/usm/explorer/scripts/status.widget.js"></script>
<script> CA_Catalog.buildWidget({type: 'status', login credentials, renderTo: 'status1', businessUnit:"London222",  layout:'layout-2', openIn: '_widget', hideCart: true} ); </script>
<div align="center" id="status1" style="width: 400px; margin-bottom: 10px; height: 100px">
	&nbsp;</div>

The first line references the JavaScript file for the Status widget.

The second line specifies the JavaScript with configuration parameters for the Status widget.

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

The third line specifies the DOM element in which the Status widget is rendered.

Key parameters and explanations follow for the CA_Catalog.buildWidget function call in the Status 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:"status"

Specifies that the widget is a Status widget.

renderTo:"status1"

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

businessUnit:"London222"

Specifies the business unit that catalog users can access while utilizing this Status widget. For this business unit and the business units under it, users can view the status of the requests for they have permission:

If you specify the root business unit, users can view the status of requests in all business units, including the root business unit. Conversely, if you specify the lowest level business unit, users can view the status of requests 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.

layout:'layout-2'

Displays the options on the Status widget as buttons in a single row. The options are Cart, Open, Closed, and Pending.

Alternatively, specify layout-1 to display the options vertically: Each option appears on its own row in a table.

openIn:"_widget"

Specifies that other widgets on the same page listens to events from the Status widget and respond to them. In this scenario, when the user clicks an option on the Status widget, another widget responds by opening the target. The targets are as follows:

Option

Target Function

Widget

Cart

Shopping Cart

Edit Request

Open

Open Requests

Request List

Closed

Closed Requests

Request List

Pending

Requests Pending Action

Request List

To enable these target functions to complete correctly when users click the option on the cart, add the following widgets to the page:

OpenIn specifies how a target opens when the user clicks it on the Status widget. Other possible values for this parameter follow:

_self

Opens the target in the catalog, on the same page.

_top

Performs the same function as _self, except that the target opens in the top-most frame of the browser. If the target is a frame, then the first associated frame in service option element is selected.

_blank

Opens the target on a new page.

_url

Opens the target using a custom URL. The URL can include a placeholder for the object ID of the source context, for example, the service.

An example follows:

http://www.google.com?id={id}

Note: You can also specify the following settings, as shown in the source code: refresh rate in minutes and hide cart.