Page Registry

The Page Registry holds information pertaining to the current page and other pages in your application. It allows a FEF developer to access a page's primary data, to access page components by their name property, and more as described below.

Accessible Methods

Here, we list method entry points on working with the Page Registry.

Get Primary Object

Gets the primary data of the current page. The primary data is either set within your pages.json file or set manually using the setPrimaryData method (explained below).

var myObject = Facade.PageRegistry.getPrimaryData();

Get Page Component

Get a page component by its name property.

In html markup
<core-popover name="varName"> </core-popover>
In behavior js
var myComponent = Facade.PageRegistry.getComponent('varName');

Get Current Page

Get the current page - this will return a page prototype.

var myPage = Facade.PageRegistry.current();

Get Page's Edit Mode

Check to see if a page is in edit mode.

var isInEdit = Facade.PageRegistry.inEditMode();

Save Page

Explicitly saves any changes on your pages without having to press the docbar save button.

Facade.PageRegistry.save();

Transition Primary Data

Transitions the instance of your primary data into a different workflow state. In the below code snippet, go is the transition that transitions the primary object to a new workflow state. wf_ is required however before the action string.

Facade.PageRegistry.transition("wf_go");

Alert User

Sends a popup displaying the alert message text. An onClose variable can be set in the second parameter to perform an action on closing of the popup.

Facade.PageRegistry.alert("A message", {
    onClose: function(){
        //perform an action on close
        //of alert
    }
});

Present Confirmation Alert

Convenience method that prompts the user with a Cancel or OK alert; commonly used to confirm with the user to continue to process an action

Facade.PageRegistry.confirm("Are you sure about that?", {
    onClose: function(){
        //execute onClick of Cancel Button
    },
    onSubmit : function(){
        //execute onClick of OK button
    }
});                            

Show Loading Message

Show a loading overlay is commonly used to force the user to wait for a server request to return. Use the startBlockingTask function, passing in a promise as the first parameter and an options object as the second parameter.

//Example - wait for an instance to load from the server
var findRequest = Facade.Resolver.find('<object type>' , '<object uid>');
Facade.PageRegistry.startBlockingTask( findRequest , { message : '<Message string>' } );

Set Primary Data

Explicitly set the primary data of a page to data in the DataRegistry. In the below snippet, we will set the primaryData of our page to data in the DataRegistry that has the key myObject.

var data = Facade.DataRegistry.get('myObject');
Facade.PageRegistry.setPrimaryData(data);

Register Page

In a FEF application, it is best practice to define your pages in the pages.json file. However, there can be circumstances where you must add pages in scripting. To do this, use the register function of the PageRegistry. The register functions takes two parameters : the page name and a page object. The page object must have a template field which indicates the templates from your template folder. It can also have any of the fields that can be included in pages.json representation of a page, as described here. Before a page is rendered within a FEF application, it's primary data must be set.

var page = {
	title : 'My Page has a Title',
	template : 'myTemplate.html',
	primaryData : {
		type : '<primary data type>'
	},
	editMode : {
		toggle : true,
		initial : true
	}
};
Facade.PageRegistry.register('myPage', page);

Switch Pages

You can explicitly change the current page by using the setCurrent method. This method returns a promise, so you can append a .then() to perform an action upon completion of the page switch.

Facade.PageRegistry.setCurrent('myPage');

Get Query Parameter

Get a query parameter with a specific key.

var urlParam = Facade.PageRegistry.getUrlParameter('<url-key>');

Prompt the User

Use the prompt convenience method to prompt the user to enter in a textbox within a popup on the screen. Use the onClose and onSubmit methods to hook into the submit button or close button of your popup prompt.

Facade.PageRegistry.prompt("What is your name?",
    {
        onClose: function(){   
            console.log("Action canceled.")
       }, 
       onSubmit: function(args)
       {
            console.log("Hi, " + args.value)
       }
    })