Search code examples
adempiereidempiere

Where do the Context fit between the GridField and the GridTab in Idempiere/Adempiere


I m trying to grasp the purpose of the following 3 concepts ( classes ) that are core functionalities in Idempiere/Adempiere.

Based on code description

I do understand that GridTab have the state of the model representing the ad_tab which is the ViewModel Part of any ad_table. simple said we will found the data bound to the ad_table.

First, for the GridField I believe is the model of the view, if I can abuse it is like the the DOM state: what do we have as fields, values of fields and events, I believe that is template view centric.

Dicovering this two ( if I m not mistaken in my analyses ) made me wonder. What do really the Ctx stands for? what state is it representing ?

The code is not commenting on this , can any body answer me?

Thanks .


Solution

  • In iDempiere the context is a Properties object that is global to the whole application.

    You can think about the context as a global set of variables that you can access from any point of the system.

    The context variables can be viewed clicking on the iDempiere icon, then navigating to the Errors tab, and then clicking on the View button, you'll find there the variables after the line:

    === Context ===
    

    Within the context you can find a lot of information:

    • Login variables: some of those starting with #, like #AD_Role_ID
    • Defaults: records that are marked as default, also starting with #, like #C_BP_Group_ID
    • Accounting related variables: those starting with $, like $C_Currency_ID
    • Global Preferences: starting with P like P|AutoCommit
    • Window Preferences: starting with P and a number, example P132|GL_Category_ID

    And then, the context variables that you're interested in, the value of each field on the windows that are open:

    • Window fields: those starting with a number, like 1|DiscountSchema - this means the field DiscountSchema in the first window opened
    • Tab fields: those starting with two numbers, like 1|2|DatePromised - this means the field DatePromised in the third tab (the number 2, tabs are numbered from zero) of the first window opened (the number 1)

    You can access those context variables using Env.getContext... methods, and you can also add and delete your own variables with methods Env.setContext...