Creating Grouplets with PeopleCode

A grouplet is the encapsulation of content from one source (for example, a component, an iScript, or external content) that is presented within the context of another fluid application page. Tiles, embedded related content, and related information are all examples of grouplets. In each of these scenarios, the grouplets are created by the system at runtime based solely on configuration details.

However, you can use methods and properties of the Field class to generate grouplets from group box fields programmatically. The following example with comments illustrates how to create a grouplet based on component content. The behavior of the grouplet can be enhanced by optional method invocations to set a target URL, where the target content is displayed, and so on.

Example

Declare Function PSURLtoNewWin PeopleCode FUNCLIB_PTPP.PTPP_HYPERLINK FieldFormula;

Local string &src_URL = PSURLtoNewWin(GenerateComponentContentURL(%Portal, %Node, MenuName.MY_MENU, %Market, Component.COMPONENT_A, Page.MAIN_A, %Action_UpdateDisplay));

Local string &tgt_URL = PSURLtoNewWin(GenerateComponentContentURL(%Portal, %Node, MenuName.MY_MENU, %Market, Component.COMPONENT_B, Page.MAIN_A, %Action_UpdateDisplay));

Local Field &fld = GetField();

/* Use the following three methods to create a display-only grouplet.    */
&fld.SetGroupletType(%GroupletNoStyle);
/* Specifies the grouplet's source content */
&fld.SetGroupletUrl(&src_URL);
/* Specifies the group box's page field name. Not used with interactive  */
/* grouplets, which render the entire component.                         */
&fld.SetGroupletID("GRPLTC_NOINTER");

/* Optional. Specifies the target URL, which makes the entire grouplet tappable. */
&fld.SetGroupletActionUrl(&tgt_URL);

/* Optional. Specifies how the action URL is opened. Default is current window.  */
&fld.SetGroupletDisplayIn(%GroupletActionInNewWindow); /*  */

/* Enable the icon for zooming to open the modal – similar to related            */
/* information in the right panel.                                               */
<* &fld.IsGroupletZoomIconEnabled = True; 
/* Modal options if %GroupletActionInModal is used for SetGroupletDisplayIn.     */
&fld.SetGroupletMOptions("bAutoClose@0;"); *>

To prevent data integrity errors in the component buffer during a user’s session, you must not provide access to the same fluid component as a grouplet or in a “modeless” manner and then again in a “standalone” manner.

Specifically, standalone access refers to navigation to the fluid component from the Navigator menu, a homepage, a dashboard, a component transfer, execution of DoModalComponentPopup, and so on. The same fluid component cannot be specified as a grouplet (that is, as dynamic tile content, embedded related content, related information, or programmatically via grouplet PeopleCode) and it cannot be displayed in a “modeless” manner (such as the zoom on related information, the modal target for a tile, through ViewContentURL, and so on).