[article rbarticle] - Client-side SDK - rbf_getPageContext(

Posted by Mohammed Siraj on 18-Dec-2015 00:30

This method will return a PageContext singleton object for this page. This object encapsulates all state & behavior of the page. This is the root level context object from which we can directly/indirectly access other top level objects like PageLocalization, FormContext, Section etc.

PageContext object interface details:


getPageType(): Will return an integer identifier for the current page. All Page identifiers are defined as properties of rb.newui.PAGE_TYPES. This API can be leveraged to have custom behavior specific to a given page, for example, differentiate between a New Record & Edit Record page, to set a default value for a field in New Record pages.


if(rbf_getPageContext().getPageType() === rb.newui.PAGE_TYPES.NEW){
rbf_getFieldContext('dateA').setValue(new Date());//set current date for dateA field on new record page

getPageId(): Will return Page ID

getPageTheme(): Will return string identifier for currently set page theme.

getLanguage(): Will return string identifier for the currently set page language. Eg. 'en' for English.

getPageLocalization(): Will return Rollbase PageLocalization object.

getLocalizedMessage(langResKey,params): Will return the externalized string label for the given language resource key. If the exteralized string is parameterized, it will replace all param tokens with values passed in 'params' argument.


rbf_getPageContext().getLocalizedMessage('Apply_Filter'), returns 'Apply Filter', if the page language is English
rbf_getPageContext().getLocalizedMessage('Enable_New_UI_for___',['Ethan']), returns 'New UI is enabled for me (Ethan)', if the page language is English

getSection(sectionId): Will return Rollbase Section object for the Page Section identified by Section ID, which should be passed as argument.

var rb_SectionObj = rbf_getPageContext().getSection(530938);

getFormDetails(formName): Will return Rolblase FormContext object identified by the form name passed as argument.

var formContext = rbf_getPageContext().getFormDetails(rb.newui.util.EDIT_FORM_NAME);

getPageComponent(componentId): Will return Rollbase PageComponent object for the top level component (i.e. Grid, Chart, Report) identified by component id. This componentId is the Page Cell ID that contains this component.

var pageComponent = rbf_getPageContext().getPageComponent(530939); // or rbf_getPageComponent(530939), where 530939 is the Page Cell ID.
pageComponent.refresh();//will refresh the Grid or Chart or Report that this pageComponent object relates to.

getPageConstructionLog(): Will return Rollbase PageConstructionLog object.

getCanvasEl(): Will return jquery object for the root canvas element that renders all the page content (that is void of Page headers & Sidebar).

To run any jquery selectors, we should leverage this method.
That is, getCanvasEl().find('input[name="fieldA"]'); will execture faster when compared to $('input[name="fieldA"]');


printPageConstructionLog(): Will print the page construction log with timing details onto console.

isPageDirty(): Will return boolean TRUE if the Page has a Object Record form with modifications. /** Will be available with Rollbase 4.0.5 release */

isRedirectedOnServerValidation(): Will return boolean TRUE to identify the scenario wherein the User was re-directed on submitting an Object Record form as it failed server-side validations.

isDialogPage(): Will return boolean TRUE, if the current New UI page is rendered in a dialog. Eg: Quick-Create pages.

Note: Will document other top-level Rollbase objects specified above such as FormContext, PageLocalization, PageComponent etc. individually.

All Replies

This thread is closed