Utils Class Methods
In this section, the Utils class methods are presented in alphabetical order.
Syntax
AnnounceText(MessageText )
Description
Use the AnnounceText method to post a message to an ARIA (Accessible Rich Internet Applications) live region of the page to be read by screen readers and other assistive technologies. An ARIA live region can appear on standard fluid pages and modal pages.
Parameters
Field or Control |
Definition |
---|---|
MessageText |
Specifies the message text as a String value. |
Returns
None
Example
(create PT_PAGE_UTILS:Utils()).AnnounceText("Test of Announcement");
Syntax
ClearConfirmationMessage()
Description
Use the ClearConfirmationMessage method to dismiss the transient confirmation message (to ensure that the message is dismissed even if auto dismiss is disabled through the user's preference settings).
Note: Methods that perform the same functions exist in the Banner class. Typically, the Utils class methods are preferred only when you have instantiated a Utils object and want to avoid instantiating a Banner object.
Parameters
None
Returns
None
Example
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
/* Some processing… */
&oUtils.ClearConfirmationMessage();
/* Additional processing… */
Syntax
CloseConfirmationMessage()
Description
Use the CloseConfirmationMessage method to dismiss the transient confirmation message (to ensure that the message is dismissed even if auto dismiss is disabled through the user's preference settings).
Note: Methods that perform the same functions exist in the Banner class. Typically, the Utils class methods are preferred only when you have instantiated a Utils object and want to avoid instantiating a Banner object.
Parameters
None
Returns
None
Example
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
/* Some processing… */
&oUtils.CloseConfirmationMessage();
/* Additional processing… */
Syntax
GetButtonState(&ButtonField)
Description
Use the GetButtonState method to return the state of a toggle button as a Boolean value.
Parameters
Field or Control |
Definition |
---|---|
&ButtonField |
Specifies the toggle button as a Field object. |
Returns
A Boolean value: True if the button state is "pressed" (or on), otherwise False.
Example
Local Field &oToggleButton = GetField();
Local PT_PAGE_UTILS &oUtils = create PT_PAGE_UTILS:Utils();
If (&oUtils.GetButtonState(&oToggleButton) Then
/* Processing for the on state */
Else
/* Processing for the off state */
End-If;
Local boolean &bState = &oUtils.ToggleButtonState(&oToggleButton);
Syntax
GetDefaultViewport()
Description
Use the GetDefaultViewport method to return the default viewport settings from the system for this device and form factor.
Note: The default viewport settings are those recommended by Oracle for each device and form factor.
Parameters
None
Returns
A String value.
Example
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
Local string &sDefViewport = &oUtils.GetDefaultViewport();
If (find("height",&sDefViewport) < 1) Then
&oUtils.SetCustomViewport(&sDefViewport | ",height=device-height");
End-If;
Syntax
SetButtonState(&ButtonField, NewState)
Description
Use the SetButtonState method to set a button field as a "stateful" button (that is, as a toggle or on/off button); use this method to initialize the button state prior to initial display. Use this method with image-only buttons or with buttons that have the psc_button-simple style applied.
Parameters
Field or Control |
Definition |
---|---|
&ButtonField |
Specifies the button field as a Field object. |
NewState |
Specifies the new state as a Boolean value. |
Returns
None
Example
/* Get the &oToggleButtonField Field object first */
(create PT_PAGE_UTILS:Utils()).SetButtonState(&oToggleButtonField, False);
Syntax
SetConfirmationMessage(MessageText)
Description
Use the SetConfirmationMessage method to display a typically transient confirmation message below the fluid banner.
Note: Methods that perform the same functions exist in the Banner class. Typically, the Utils class methods are preferred only when you have instantiated a Utils object and want to avoid instantiating a Banner object.
Parameters
Field or Control |
Definition |
---|---|
MessageText |
Specifies the message text as a String value. |
Returns
None
Example
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
/* Some processing… */
&oUtils.SetConfirmationMessage("Your operation was successful.");
/* Additional processing… */
Syntax
SetCustomViewport(ViewportText)
Description
Use the SetCustomViewport method to set the viewport to a custom size.
Parameters
Field or Control |
Definition |
---|---|
ViewportText |
Specifies the viewport attributes as a String value. |
Returns
None
Example
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
If (%Request.GetParameter("CUSTOMVIEWPORT") <> "") Then
&oUtils.SetCustomViewport(&oUtils.GetDefaultViewport() | ",height=device-height");
Else
&oUtils.SetDefaultViewport();
End-If;
Syntax
SetDefaultViewport()
Description
Use the SetDefaultViewport method to set the viewport to the default system settings.
Important! Setting the viewport for each fluid component ensures that your fluid applications operate properly across all device types, particularly on small form factor devices such as smart phones. This method is the recommended approach for setting the viewport because it sets the recommended defaults.
Parameters
None
Returns
None
Example
(create PT_PAGE_UTILS:Utils()).SetDefaultViewport();
Syntax
SetFavIcon(image_ID)
Description
Use the SetFavIcon method to set a component-specific favicon—also known as a shortcut icon, website icon, tab icon, URL icon, and so on. When the fluid component is accessed by a user, this favicon is displayed in the browser tab instead of the default favicon.
Parameters
Field or Control |
Definition |
---|---|
image_ID |
Specifies the ID for an image stored in the PeopleTools image catalog. |
Returns
None.
Example
Note: The image_ID can also be specified as Image.IMAGE_ID.
import PT_PAGE_UTILS:*;
Local PT_PAGE_UTILS:Utils &oUtils = create PT_PAGE_UTILS:Utils();
Local string &image = "MY_LOGO_FAVICON";
&oUtils.SetFavIcon(&image);
Syntax
ToggleButtonState(&ButtonField)
Description
Use the ToggleButtonState method to toggle the current state of a toggle button and returns the new state as a Boolean value.
Parameters
Field or Control |
Definition |
---|---|
&ButtonField |
Specifies the button field as a Field object. |
Returns
A Boolean value.
Example
/* Get the &oToggleButtonField Field object first */
Local boolean &bState = (create PT_PAGE_UTILS:Utils()).ToggleButtonState(GetField());