Refreshing the parent screen when its secondary pop-up window is closed
Summary
As an application developer, you have designed a section on a harness with a button that opens a pop-up window. The pop-up window allows users to edit information and close the pop-up. When clicked, the Close button in the pop-up window should close the pop-up and refresh the parent screen at the context where the pop-up window opened. To achieve this synchronized button and window behavior for your application, follow the Suggested Approach. It explains how to create a function to manage the timing of the pop-up window closure and the refresh of the parent window.
Suggested Approach
To design a pop-up window with a Close button that closes the pop-up and refreshes the parent window where the pop-up opened, complete the following steps:
- Create a property, for example, myHiddenProp, on the parent window to be refreshed. This can be a standard property of type Text.
- Make the property hidden: In the Cell Properties, on the Advanced tab, specify the Inline Styledisplay:none;.
- Specify the ONCHANGE event of this property to be Refresh this Section.
- Save the UserWorkForm HTML Fragment rule into an open RuleSet version and add the HTML Source script shown below.
The functions in the script are invoked when users click the Close button in the pop-up window to close the current window and refresh the parent.
<script>
CloseWindow = function(){
window,close ();
}RefreshParentAndCloseWindow = function(){
var ParentObject = window.opener;
ParentObject.document.getElementByID(“myHiddenProp”).fireEvent(‘onchange’);
setTimeOut(CloseWindow,5000);
}
</script>The CloseWindow() function closes the current window (the pop-up) after the specified time interval.
The RefreshParentAndCloseWindow() function gets the parent object and fires the ONCHANGE event on myHiddenProp property that refreshes the section. - To open the pop-up window, specify the Behavior of the pxButton control that will open the pop-up window as shown in the following screens:
- For Event, select Click.
- For Action, select Harness.
- For Target, select Pop-up Window.
- For Class, specify the class.
- For Harness, specify PopupHarness.
- For Read Only, select No.
- Specify the pop-up window dimensions, Window Width and Window Height.
- To call the function specified in Step 4, the UserWorkForm, RefreshParentAndCloseWindow(), specify the Behavior of the pxButton control that will close the pop-up window and refresh the parent window as shown in the following screens:
- For Event, select Click.
- For Action, select Run Script.
- For Function Name, specify RefreshParentAndCloseWindow.
- To test this design at runtime, complete the following steps in the runtime application, as illustrated by the example of this procedure:
- Click the button that you designed to open the pop-up window. In the open pop-up, edit the information as appropriate to your application.
- Click the button you designed to close the pop-up window and refresh the parent screen.
Close the composite portal and reopen it.
Verify that the section with the embedded controls to open and close pop-up windows displays the latest information, the edits you made in Step 7a.
- Click the button that you designed to open the pop-up window. In the open pop-up, edit the information as appropriate to your application.