4D v13.4

Programmed management of Web Areas

Home

 
4D v13.4
Programmed management of Web Areas

Programmed management of Web Areas  


 

 

The commands of this theme are dedicated to the programmed management of Web Area type form objects.

Web areas can display any type of Web content within your 4D environment: HTML pages with static or dynamic contents, files, pictures, Javascript, Flash, PDF,etc. and even MS Office documents (under Windows when MS Office is installed). The following picture shows a Web area included in a form and displaying an HTML page:

In addition to the commands of the Web Area theme, several standard actions and form events allow the developer to control the functioning of these Web areas. Specific variables can be used to exchange information between the area and the 4D environment. These tools can be used to develop a basic Web browser in your forms.

A Web area is created using a variant of the Plug-in Area/Subform button found in the object bar of the 4D Form editor (for more information, please refer to Web areas in the Design Reference manual).

Like other dynamic form objects, a Web area has an object name and a variable name, which can be used to handle it by programming. The standard variable associated with a Web area object is of the Text type. More specifically, you can use the OBJECT SET VISIBLE and OBJECT MOVE commands with Web areas.

Note: The text variable associated with the Web area does not contain a reference therefore it cannot be passed as a parameter for a method. For example, for a Web area named MyArea, the following code cannot be used:

 Mymethod(MyArea)

Code for Mymethod:

 WA REFRESH CURRENT URL($1`Does not work

For this type of programming, you will need to use pointers:

 Mymethod(->MyArea)

Code for Mymethod:

 WA REFRESH CURRENT URL($1->) `Works

In order to be displayed, the Web areas must be included in windows designed in "compositing mode." This internal mode for handling windows under Mac OS is not used in all the 4D windows.
In 4D v11 SQL, the windows designed in "compositing mode" are:

  • The windows generated by the Open window and Open form window commands having the type Compositing Mode (constant value 4096);
  • In Design mode, windows displaying a project form.

Note: Certain former generation objects are not compatible with the compositing mode (for example 4D Chart areas). If they are displayed in windows in compositing mode, these objects will not work.

In addition to the standard object variable (see previous paragraph), two specific variables are automatically associated with each Web area:

  • The "URL" variable
  • The "Progression" variable.
    By default, these variables are named, respectively, areaName_url and areaName_progress. You can change these names if desired. These variables can be accessed in the Property List:

"URL" is a String type variable. It contains the URL loaded or being loading by the associated Web area.
The association between the variable and the Web area works in both directions:

  • If the user assigns a new URL to the variable, this URL is automatically loaded by the Web area.
  • Any browsing done within the Web area will automatically update the contents of the variable.
    Schematically, this variable functions like the address area of a Web browser. You can represent it via a text area above the Web area.

URL Variable and WA OPEN URL command
The URL variable produces the same effects as the WA OPEN URL command. The following differences should nevertheless be noted:

  • For access to documents, this variable only accepts URLs that are RFC-compliant ("file://c:/My%20Doc") and not system pathnames ("c:\MyDoc"). The WA OPEN URL command accepts both notations.
  • If the URL variable contains an empty string, the Web area does not attempt to load the URL. The WA OPEN URL command generates an error in this case.
  • If the URL variable does not contain a protocol (http, mailto, file, etc.), the Web area adds "http://", which is not the case for the WA OPEN URL command.
  • When the Web area is not displayed in the form (when it is located on another page of the form), executing the WA OPEN URL command has no effect, whereas assigning a value to the URL variable can be used to update the current URL.

"Progression" is a Longint type variable. It contains a value between 0 and 100, representing the percentage of loading that is complete for the page displayed in the Web area.
This variable is automatically updated by 4D. It is not possible to modify it manually.

Specific form events are intended for programmed management of Web areas, more particularly concerning the activation of links:

  • On Begin URL Loading
  • On URL Resource Loading
  • On End URL Loading
  • On URL Loading Error
  • On URL Filtering
  • On Open External Link
  • On Window Opening Denied

In addition, Web areas support the following generic form events:

  • On Load
  • On Unload
  • On Getting Focus
  • On Losing Focus

For more information about these events, please refer to the description of the Form event command.

When the form is executed, standard browser interface functions are available to the user in the Web area, which permit interaction with other form areas:

  • Edit menu commands: When the Web area has the focus, the Edit menu commands can be used to carry out actions such as copy, paste, select all, etc., according to the selection.
  • Context menu: It is possible to use the standard context menu of the system with the Web area (display of the context menu can be controlled using the WA SET PREFERENCE command).
  • Drag and drop: The user can drag and drop text, pictures and documents within the Web area or between a Web area and the 4D form objects, according to the 4D object properties.

Under Windows, the Web area can support the display and modification of Microsoft Office documents (when Microsoft Office is installed on the machine). In particular, Word, Excel and Powerpoint documents (.doc, .xls and .ppt extensions) can be handled. The MS Office XML format is also supported.

Note: MS Office 2007 does not allow the display of documents in a Web browser by default; they are always opened in a new window. You can modify this functioning using the instructions provided at the following address: http://support.microsoft.com/kb/162059/en-us

Under Windows, Web areas can be used to display local or external folders via the ftp:// protocol or via network pathnames (\\myserver\myvolume).

Under Windows, it is not recommended to access, via a Web area, the Web server of the 4D application containing the area because this configuration could lead to a conflict that freezes the application. Of course, a remote 4D can access the Web server of 4D Server, but not its own Web server.

The URLs handled by programming in Web areas under Mac OS must begin with the protocol. For example, you need to pass the string "http://www.mysite.com" and not just "www.mysite.com".

 
PROPERTIES 

Product: 4D
Theme: Web Area