ObjectGears Help

           
Forum   ObjectGears (Version: 1.6.0.0)

Scripts of administration pages

It is possible to use scripts on some administration pages. In this way you can easily enhance page functionality according to your needs:

  • you can add a new button to the toolbar for starting your actions
  • you can respond to actions on the page, e.g. saving a record, unlocking user account...
  • you can add a new control to the page for displaying further information

Scripting is not meant for supressing ObjectGears system functionality, but for extension by your functions.

Scripting is enabled on following pages with these events:

Page Event
List of users OnLoad
List of users OnPreRender
User detail OnLoad
User detail OnAfterSave
User detail OnUndeletePerson
User detail OnPreRender
Information about user OnLoad
Information about user OnAfterSave
Information about user OnPreRender
Role administration OnLoad
Role administration OnPreRender
Role detail OnLoad
Role detail OnAfterSave
Role detail OnPreRender
Model detail OnLoad
Model detail OnAfterSave
Model detail OnPreRender

Every event can be defined in the script only once. It is no problem, if some event is not defined. To increase clarity you can create other function in the script. However, these functions cannot collide with event names.

Description of events

All the events are defined in the script in the same way, just with a diffrent function name.

Example of an event definition:

function OnPreRender()
{
  ...
}

OnLoad

This event starts load of the page on server. It corresponds with ASP.NET event OnLoad.

OnAfterSave

This event occures after saving page data. In case of an error in the script saving is not cancelled.

OnUndeletePerson

It is possible to activate again a user on page with user detail. This event occures after this activation.

OnPreRender

This event occures after the page is rendered on the server. It corresponds with ASP.NET event OnPreRender.

Script objects

There are various script objects available on particular pages. They are described in the following table.

Page Object Description
all pages OGForm Form for work with controls on the page.
Information about user Person OGPerson Instance of currently displayed user.
List of users OGDoFilter() Function for filter application.
List of users OGClearFilter() Function for filter cancellation.

In order to work with scripts it is necessary to know name of the controls that can be used. Following table contains list of available names.

Page Control Description
List of users TextItem fName Text field for user filtering.

Examples of use

Putting a button to the page

¨This script inserts a button to the toolbar. After clicking on the button text ac is added to the text field for user filtering.

function OnLoad()
{
  OGForm.Toolbar.CreateButton( 'b1', 'Button', './images/archive.png');
}

function b1_Click()
{
  OGForm.SetSuccess( 'You have clicked on the button B1');
  /*OGForm.RedirectToErrorPage('error'); */
}

Setting up a field for filtering users

This script sets up a text field for filtering the users on page with the list of users.

function OnLoad()
{
  OGForm.Toolbar.CreateButton( 'b1', 'Tlačítko', './images/archive.png');
}

function b1_Click()
{
  OGForm.GetControl( 'fName').Text = 'ac';
}

Access restriction to the page Information about user

ObjectGears in the default set up enable all the users to access page Information about user (PersonQuickInfo) with data of whatever user. The page is displayed after clicking on reference to the user.

It may be necessary to modify this default behaviour in certain situations (e.g. in situation, when ObjectGears instance is shared by more users that shall not know each about another). This can be achieved by using following script in the page PersonQuickInfo. This page is then available only to Administrator or in case that the current user is identical to the user whose data shall be displayed on the page (this means that clicking on the user name in the upper right screen corner will always work).

function OnLoad()
{
  if (!( OGPerson != null && ( OG.Person.IsUserAdmin() || OGPerson.Id == OG.Person.GetLoginPerson().Id )))
  {
    OGForm.RedirectToAccessDenied('Only administrator can access this page.');
  }
}

This website is using cookies files to provide services and analyse visits. You agree with that by using this website.     Further information