OnLoad - cWebObject

Called for each cWebObject during LoadView or LoadWebApp

Type: Event

Parameters: None

Procedure OnLoad 


Called for each cWebObject during LoadView or LoadWebApp. The event is called before the published (web) properties are serialized.

Can be used to:
- Modify an object's published properties as a view is being loaded,
- Call client actions to be executed after the view/webapp is loaded,
- Set web properties as the view/webapp is loaded.


Object oCustomerView is a cWebView
    Object oCustomer_DD is a Customer_DataDictionary

    Set Main_DD to oCustomer_DD
    Set Server to oCustomer_DD
    Procedure OnLoad
        Send Find of oCustomer_DD FIRST_RECORD 1


Normally you would use the Set command to assign a value to a Web Property during OnLoad, since this is where initial values are being set. The use of WebSet is allowed, but only needed if value of the property needs to be sent from the client to the server on the next request.

To illustrate this, if the code below is used in customer.wo and in one browser we log in as 'guest' and in another browser as 'admin' or 'john', we see a '0' or a '1' being displayed in the oStatusDisplayer object when we browse thru the customers. This means there is no difference between the result of WebGet and Get. When you need the value passed from server to client, you would need to use WebSet in the Onload event.

Object oStatusDisplayer is a cWebForm
    Set piColumnSpan to 4
    Set psLabel to 'Status'

    Procedure OnSetCalculatedValue String ByRef sValue
        WebGet pbRender of oCustomerCustomer_Number to sValue

Object oCustomerCustomer_Number is a cWebForm
    Entry_Item Customer.Customer_Number
    Set piColumnSpan to 4
    Set piColumnIndex to 0
    Set psLabel to "Customer Num:"
    Set peLabelAlign to alignRight

    Procedure OnLoad
        Integer iUserRights

        Get piUserRights of ghoWebSessionManager to iUserRights
        Set pbRender to (iUserRights<>0)

Use OnShow as a hook for things like navigation changes.

See Also

Web Properties