[Contents] [Previous] [Next] [Last]

Chapter 2
A Tour of Visual JavaScript

This chapter introduces the Visual JavaScript windows and tools that you use to develop applications. The chapter describes how to invoke each window and introduces the basic usage of each.

The component model allows you to assemble applications by collecting and connecting the ready-made components, which already have behavior programmed into them. In a visual programming environment, much of the work of building an application consists of selecting the components you want and placing them together into a window that represents a single HTML page of your finished application. All of the tasks of application building are accessible through the menu bar and toolbar in the main application window. (See "Main Application Window.")

In Visual JavaScript, a project keeps track of the pages and other source files that make up your application. The Project window shows you the contents of your current project and lets you open, add, or remove pages. (See "Project Window.")

When you open a page to work on, it is displayed in a Page Editor window, where you can add components and create the layout of the visual elements that your end user will work with. (See "Page Editor.") You add components by dragging them onto the page from the Component Palette. (See "Component Palette.")

When you have chosen components, you must customize their appearance and behavior, and connect them together to form your specific application. You do this by setting their properties in the Inspector, and making connections in the Connection Builder. (See "Inspector," and "Connection Builder.") You can then test the behavior either by previewing individual pages of the application on the client side, or deploying it on the server and using the JavaScript Debugger to identify problems. (See "JavaScript Debugger.")

As you use these windows to develop your crossware application, you will also encounter a number of other special builders and editors that help you with programming tasks. These tools can even eliminate tasks by generating parts of your application entirely automatically. (See "Additional Tools.")

Main Application Window

The main application window appears when you start Visual JavaScript. It contains a menu and toolbar that give you access to all of the commands and tools that you use to build applications.

A number of working windows appear within the main window as you create and inspect the parts of your application. You can be size and place these windows however you choose. Figure 2.1 shows a convenient layout.

Figure 2.1    The Visual JavaScript main application window

When you select a command from the menu bar or toolbar, the command usually applies to the currently selected object in the currently active window. Menu items that cannot apply to the currently selected object are disabled. A window becomes active when you click in it, and the active window is distinguished by the color of the frame. In the Project window, select an object by clicking its name. The name is highlighted to indicate selection. In the Page Editor, you can click a component to select it in the Layout view, where it is distinguished by a blue outline, or you can click an HTML tag in the Structure view, where it is highlighted to indicate selection.

In addition to the toolbar and menu bar, many of the working windows have context menus that appear when you right-click an object or the background of the window. The context menus give you access to frequently used commands, which usually apply to the currently selected object in the window. Additional help is often available through the What's This? or More Info commands on the context menu.

The individual working windows are described in the sections that follow.

Project Window

The Project window shows and gives you access to all of the files that make up your application. You also use this window to view the data sources that are available for database-connected applications. The files you work with directly are the HTML page files, listed first in the file tree structure.

When you create or select a project on start-up or by using the File menu, it is displayed in the Project window, as shown in Figure 2.2. You can also invoke the Project window by choosing Project from the Window menu.

Figure 2.2    The Project window

You can create, load, save, and work with projects using the commands on the Project menu. Right-click an item in the Project window to display a context menu containing commands that apply to the selected item, or use the commands on the Project and File menus.

Each HTML page in your project is listed under Pages in the Project window, where you can double-click it to display it in a Page Editor. As you add components to your pages, the required source files for those components are automatically added to the project and listed in the Project window.

Although data sources are not part of an individual project, the Project window also shows you which data sources are available on the deployment server and allows you to identify new ones. (See "Identifying Data Sources" for more information.) You can click the "+" icon to open a data source and see the tables and columns defined in it.

You can use the Project window to import specific files into your project. You can import existing HTML pages into the project in order to re-use them, modify them, or incorporate elements of them into your application. You can also import image files, so that they are available locally and delivered with the application. (See "Adding Pages and Files to a Project" for more information.)

When you move the cursor over a file in the Project window, a tool tip appears, showing the full file name. For image files, the tool tip shows a thumbnail version of the image.

Page Editor

The Page Editor is where you create, add to, and modify the page contents of your application. When you double-click an HTML page file in the Project window, a visual representation of the page appears in a Page Editor window. Each page appears in its own Page Editor window. As you build a page visually, Visual JavaScript creates and maintains the HTML code for the page.

The Layout view that first appears shows your components visually. For visual components, this view shows approximately how the finished page will look to the end user. This is the view in which you do most of the work of building the page. However, you can display the page using any of three views: Layout, Structure, or Source. To see and work with a structured view of the HTML code that is generated as you build the page visually, select the Structure view. To see the actual HTML source code, choose the Source view.

Select a view in any of the following ways:

Layout View

The Layout view displays the page in WYSIWYG format, although not exactly as the user sees it. This is partly because the nonvisual components are shown along with the visual components and text. Also, the design-time appearance of visual components is often different from their runtime appearance, which can be modified or completely generated by Java or JavaScript code, dynamically reflecting runtime information such as data from a database.

You can add a component to the page by dragging it from the Component Palette into the Layout view of the Page Editor. You can also enter text directly into the Layout view at the cursor location to create labels and descriptions. You can insert carriage returns from the keyboard to create new lines, add HTML elements using the Insert menu, format text using the Format menu or formatting toolbar, and drag components to existing lines in order to change their positions. For a more complete description of your options for editing pages, see "Editing Pages."

Structure View

The Structure view displays a hierarchical organization of the HTML code for the page. Use this view to work more directly with the generated HTML. A component generally corresponds to more than a single HTML tag. In the Structure view, you can select and inspect not only the component, but also the tags within a component. You can drag and drop HTML tags within the page's Structure view, or to the Palette, from which you can drag them to other pages.

When you select a page element in the Layout view, the corresponding HTML tag is selected in the Structure view. When you select an HTML tag in the Structure view, the corresponding page element is selected in the Layout view. The cursor is inserted in text to indicate selection. Selected objects in the Structure view also appear in the Inspector, where you can examine and change their properties.

Source View

The Source view displays the HTML source code for the page. To make the HTML code more readable, click Reformat Source in the upper-right corner of the window to automatically insert lines breaks as appropriate.

NOTE: Direct editing is not supported in the Source view for this release; however, you can choose any other editor to edit the HTML source directly. See "Using an HTML Editor to Edit Pages" for more information. §

Component Palette

The Component Palette is a collection of components that can be used to construct HTML pages. To add a component to a page, drag it from the Palette and drop it onto the page in the Layout or Structure view of the Page Editor.

To display the Component Palette, click Palette in the toolbar or choose Palette from the Window menu. Move the cursor over a Palette item to display a tool tip that describes the component. Double-click a Palette item to call the Inspector and display the component's properties.

A default set of components is available that includes HTML form elements, JavaScript components, LiveWire database-access components, and Java components. Components of different types are organized into tabs. The Form tab of the Component Palette is shown in Figure 2.4.

Figure 2.4    Default Form components on the Component Palette.

By default, there are five tabs available for the Component Palette. Additional tabs can be added or imported. These are the default tabs.

Form. Standard HTML form elements, such as text fields, check boxes, and buttons. (See "Form Tab.")

HTML. Components such as Table, Image, and Link, that are made of standard HTML tags or blocks. (See "HTML Tab.")

Database. JavaScript and Java components that let you connect to specified databases and make use of the LiveWire database functionality. (See "Database Tab.") These include:

Other. Java and JavaScript components that are not specifically intended for database access, such Date Display and Scrolling Message. (See "Other Tab.")

Test. Sample components intended for testing or learning about database access pages. These include the Java Dummy Cursor, the JavaScript Dummy Cursor, and the Java Form. (See "Test Tab.")

Each of the built-in components is described in detail with a list and description of all properties, methods, and events in Part 2, "Component Library Reference."

You can customize and extend the Component Palette in a number of ways:

Right-click anywhere on the Palette to display a context menu that you can use to perform common Palette commands, or use the Edit Component Palette menu in the Edit menu.

For more information, see Chapter 8, "Customizing the Development Environment."

Inspector

Components have properties that control their appearance and behavior. System objects, such as projects and pages, also have properties. Use the Inspector to examine and change properties. You can display the Inspector in any of the following ways:

Figure 2.5 shows the Inspector window.

Figure 2.5    Inspection of a selected Form component

When the Inspector is active, it always displays the properties of the currently selected component or object. Simply click an object in the Page Editor, Project window, or Component Palette to see its properties.

The Inspector generally displays properties, events, and methods for the selected component. For selection-list components, it also displays the selection options. Project properties specify deployment information such as deployment location and project name. Component properties specify such things as the component name, contents, and appearance.

Inspecting Properties

The Inspector displays the name of each property on the left and its value (if any) on the right. You can change the relative sizes of the name and value columns by dragging the line between them to the right or left.

When a property is read-only, you can inspect the value but cannot edit it. For editable properties, you can type text directly into the value cell to change the value of the property.

At the right edge of the value cell there can be one or more buttons: an ellipsis (...), an equal-sign (=), or a downward-pointing arrow. These buttons bring up a custom property editors suitable to the property.

Complete custom component editors are also available for some components. When you inspect such a component, the custom editor appears either inside the Inspector or in a separate window in addition to the Inspector. (See "Using Custom Component Editors.")

NOTE: If you have created a component of your own that includes its own custom editor (called a Bean Customizer), the Inspector will automatically make it available when you inspect the component. §

Inspecting Events and Methods

The Inspector displays the user input and value change events that can be detected by a component. Click the ellipsis (...) at the right of the field to bring up the Connection Builder, in which you can examine or create client-side connections to a particular event.

The Inspector displays the methods that are defined for each component, with any parameters and type information. When you make a component the target of an Event connection in the Connection Builder you can choose to call a method in response to the source event. The methods of the target component are listed. When you select a method that has parameters, you can specify them in a dialog box. (See "Connecting Components.")

Connection Builder

The Connection Builder allows you to add behavior to your client-side components by connecting a user event (such as a mouse click) in one component to a method or property in another component. When the user of your application takes an action (such as clicking a button), the connection you have built can cause another client-side component to change. For example, a click can cause a table to be updated with new data.

There are three ways to bring up the Connection Builder:

You can choose to edit an existing connection for the source component, or you can create a new one. The appearance of the Connection Builder varies according to the kinds of components you choose and the type of the connection. The most common choices for the kinds of components you are connecting are automatically selected as default values, as shown in Figure 2.6.

Figure 2.6    The Connection Builder

The top section of the Connection Builder shows the source component, and allows you to select a source event and connection type.

NOTE: The Connection Builder always shows the currently selected object as the source component, as long as it is a connectable object. If you click another connectable component in the Page Editor, that becomes the current selection, and the new source component. If you are in the middle of building a connection, a message appears to warn you that the current connection information will be discarded. §
The bottom section of the Connection builder shows the target of the connection.

See "Connecting Components."

NOTE: The Connection Builder makes only client-side connections. To make connections to or between server-side components, you can set properties to refer to other components or property values. For more information, see Chapter 5, "Adding Behavior to an Application." §

JavaScript Debugger

Visual JavaScript includes the Netscape JavaScript Debugger. The Debugger feature allows you to debug client-side JavaScript code. The Debugger currently cannot be used to debug server-side JavaScript or HTML. (A server-side JavaScript debugger will be available with Enterprise Server 3.5.)

To start the Debugger with the current page loaded, click Debugger on the toolbar or choose Debugger from the Tools menu.

See "Testing and Debugging Applications."

Additional Tools

In addition to the main windows described here, there are a number of tools that help you perform programming tasks automatically. These are variously accessible from the Connection Builder, the Inspector, and directly from the menus.

Database Application Wizard

The Database Application Wizard is a tool that automatically generates pages to perform the data access task you specify. The tool creates and connects all of the needed components and pages to perform the following kinds of tasks:

Choose Database Application Wizard from the Tools menu to start creating your own database application. See "Using the Database Application Wizard."

Custom Editors

Custom property editors help you build code expressions by generating correct syntax as you choose from lists of possible values, thus eliminating many typing errors that can waste debugging time. Other editors help you create or customize components.


[Contents] [Previous] [Next] [Last]

Last Updated: 11/06/97 13:24:48


Copyright © 1997 Netscape Communications Corporation