IBM Business Monitor, V8.0.1 > Reference > Developing for Monitor dashboard spaces
Opening temporary pages using code
You can code a widget to open a page from another Monitor dashboard space as a temporarily visible page. The page can have data relevant to the current space.
You must know the ID ( pid) of the page that you want to open. Additionally, if you want the widgets in the page to contain contextual data, you need to know which events the widgets handle so that you can pass this data through these events.
You can code a widget so that it behaves as if there were a Page Navigator widget with an Open Page action wired to it. That is, the widget makes a page from another space temporarily visible in the current space. You can use this functionality to reuse an existing page instead of creating similar pages in different spaces.
For example, if a call center business space already has a Create Sale page, and a retail space needs a similar page, you can reuse the existing page. Code a widget in the retail space to reuse the Create Sale page from the call center space. You add the code to a user action such as clicking a Create Sale button. Additionally, you can pass data to make the page specific to the retail context to replace the data that is specific to the call center.
If the user is a viewer, editor, or owner of the page, the space automatically switches to the temporary page so that the user immediately sees its contents. The user can then interact with the temporary page like any other page in the space, including switching to other pages. The temporary page remains visible in the space until the user leaves the space or a widget closes it. If the user leaves the space and then returns, the temporary page is no longer in the space. The user must repeat whatever action opened the temporary page to reopen it.
Procedure
To open a temporary page in the current space, code your widget to call the com.ibm.mashups.builder.iEvent.OPEN_PAGE event and pass one of the following payloads:
- A String containing the ID of the page that you want to open.
- A JSON object containing a pid set to the page that you want to open and an eventsArray containing the events to be broadcast to the widgets on that page. The event objects in the eventsArray must have the following format:
{targetEvent: targetEvent, payload: payload, payloadType: payloadType}
For example:
var arrayOfEventObjects= [{targetEvent: "xxxx", payload: "xxxx", payloadType: "xxxx"}]; com.ibm.mashups.iwidget.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.iEvent.OPEN_PAGE",payload);
What to do next
The temporary page closes automatically when the user leaves the space. However, if you want to close the temporary page while the space is still open, code a widget to call the com.ibm.mashups.builder.iEvent.CLOSE_PAGE event and pass the pid of the page in the payload. If that you cannot use the CLOSE_PAGE event to close a page that belongs to the dashboard. You can only use it to close a temporary page.
Developing for Monitor dashboard spaces
Related tasks:
Create widgets
Switching pages using code