dark_mode EN
  • Method WDoc :Reload
  • Parameters
    cAction

    Name of the 'action' type method to be executed. By default, blank, indicating that only the default page will be loaded.

    cDocument

    Name of the document to be executed. By default, the current one.

  • Return value
    NIL

It allows you to instantly reload the document. It is recommended to use it every time you update a persistent property of the document and need to reload the document with the new information. The persistence system is important to understand: All PERSISTENT properties are saved in a JSON file within each user session. They are saved exactly when the CGI is deployed, and they are retrieved at the same time the WDoc object is instantiated. For this reason, the following limitations must be taken into account:

  • You can only set the initial value of a persistent DATA in the class definition itself. Anything else causes the persistence value received by the session to be lost.
  • When you set the value of a persistent DATA, it will ONLY have that new value, in all subsequent code and the next time you run the CGI.
  • When WDoc is instantiated, the first thing that runs is its DocStart() method, then any methods you have specified as services or actions, and finally all the sections you have registered with the WDoc:RegisterSection( ) method.
This method is actually a trick to force a reload of the page so that the PERSISTENT DATA is updated. For example:
METHOD Frm_SectionCheck( hParams ) CLASS WDocMain
  LOCAL cUser := hParams[ "user" ]
  LOCAL cPass := hParams[ "password" ]
  IF cUser == "admin" .AND. cPass == "1234"
    ::cUser := cUser
    Document:Reload()
  ENDIF
RETURN oSection
However, there is a more elegant way to do this, without reloading, which is using the WDoc:RegisterSection method. This method allows you to set sections that will be processed after the 'Action' or 'Post' method you specified has been executed. Therefore, the solution is simple: minimize the code you place in the StartDoc() method and place it in sections that you will register with the RegisterSection() method.

Previous chevron_left Next chevron_right