Tools Guide



Chapter 11   Programming Editor

The Programming Editor is part of the SilverStream integrated development environment (IDE). You use the Programming Editor to create and modify Java code using Java APIs and the SilverStream API.

To facilitate this process, the Programming Editor automatically generates Java code for specific SilverStream API classes and method signatures associated with objects you create in the SilverStream Page Designer, Form Designer, and Business Object Designer. You can then fine-tune your application by adding your own programming logic.

Even if you prefer not to use the SilverStream IDE, the Programming Editor provides an interface that lets you develop code in your favorite external editor or IDE, as described in Using an external editor.

Here is a sample Programming Editor window, invoked from the Form Designer:

This chapter includes the following topics:

Concepts you should know   Top of page

The Programming Editor is the tool you use to write the Java code for your SilverStream application. Before working with the Programming Editor, you should review these concepts:

Programming modes   Top of page

In the SilverStream IDE, the Programming Editor offers two programming modes:

Method signature   Top of page

The signature of a method consists of the name of the method, the names and types of its parameters, and its return value type.

The SilverStream Programming Editor automatically creates signatures for SilverStream API methods--such as event handlers--associated with objects that you create in forms and pages. You can add your own code to fill in the functionality for these methods.

In some cases, SilverStream automatically generates entire methods--such as constructors, dispatchers, and init().

NOTE   You should not modify methods that SilverStream generates for you. Your changes will be lost when the methods are regenerated at compile or save time.

For more information, see Anatomy of the Java class file and Programming in Java mode.

Event handler   Top of page

An event handler is a method that responds to a particular event, such as user interaction with GUI controls in an application. Examples of events are clicking a button, pressing a key, giving focus to a control, updating a row in a database, and loading a page in a browser.

The Programming Editor lets you easily develop event-triggered code for pages, forms, and business objects by automatically creating method signatures for event handlers, and dispatchers that call event handlers based on user interaction.

For more information, see Writing event-triggered code.

What you can do with the Programming Editor   Top of page

To provide flexible support for Java code development, the SilverStream Programming Editor allows you to work within the SilverStream IDE or connect to your favorite external tools.

In the SilverStream IDE   Top of page

When working in the SilverStream IDE, you use the Programming Editor to write Java code in the Page Designer, Form Designer, and Business Object Designer. You can write your own Java code from scratch or use a Simple Actions interface (with forms only) that automatically translates high-level actions into Java code.

The Programming Editor gives you access to the full Java language, Java APIs, and the SilverStream API so that you can write:

As you develop Java code in the SilverStream IDE, the Programming Editor gives you the following capabilities:

In an external IDE   Top of page

If you prefer not to use the SilverStream IDE, you can connect through the Programming Editor to the external code editor or IDE of your choice. At a minimum, the Programming Editor provides the following capabilities for external development:

Beyond these capabilities, you can configure your external environment to access the SilverStream API packages and, therefore, compile your SilverStream application externally. The only parts of the SilverStream API you cannot access in an external Java development environment are the elements that are used exclusively for SilverStream pages, forms, and views.

For more information, see:

Anatomy of the Java class file   Top of page

When you work in the SilverStream IDE, the Programming Editor helps manage the structure and content of your Java class file. Each Java class or Java interface you define in the Programming Editor is associated with its own code file. For example, each page, form, or business object you create in the SilverStream Designer has an associated Java source file that you can access from the Programming Editor.

This section describes how the code is organized in a Java source file and explains which Java constructs are generated automatically as you build your application. It includes the following topics:

How SilverStream organizes Java code   Top of page

The Programming Editor organizes your Java source file according to Java conventions, as follows:

When SilverStream creates Java constructs for you automatically, they are generated in the appropriate section. You can easily access these sections by using controls in the Programming Editor dialog.

For more information about automatically generated code, see Code generated by SilverStream.

Code generated by SilverStream   Top of page

If you develop your applications in the SilverStream IDE, the Programming Editor creates certain Java constructs automatically. Code generated by SilverStream is clearly marked by the comment line:

The following example shows three methods generated automatically by SilverStream:

NOTE   You should not edit code that is generated automatically. Your changes will be lost when the code is regenerated at compile or save time.

SilverStream generates the following Java constructs for you in the Programming Editor when you create forms, pages, and business objects:

Chroma-coded programming environment   Top of page

The Programming Editor provides a chroma-coded programming environment in which color is used to highlight code elements for easy differentiation and detection when you scan your source file.

Here is the color scheme:

Color

Meaning

Blue

Java reserved words

Brown

Quoted strings

Green

Comments

Red

Syntax errors that can appear after you have tried to compile

Black

All other code

If you have a color printer, you can print your Java source file as a chroma-coded listing from the Programming Editor. For more information, see Printing your code listing.

Accessing the Programming Editor   Top of page

You can interact with the Programming Editor in the following contexts:

To develop

Use the Programming Editor in the

HTML client applications

Page Designer

Java client applications

Form Designer

Enterprise-specific business logic for server-side applications, as well as utility objects

Business Object Designer

To access the Programming Editor:

  1. Start up the Page Designer, Form Designer, or Business Object Designer.

  2. Choose one of these methods:

    From

    Access the Programming Editor by

    Page Designer or Form Designer

    Selecting one of the following:

    • The Show Programming Editor button from the toolbar:

    • Programming Editor from the View menu

    • The object you want to program and double-clicking the mouse button

    Business Object Designer

    Opening a business object

NOTE   If you invoke the Programming Editor from the Form Designer, you have the option of programming your form using Simple Actions as well as writing your own code in Java mode. Simple Actions mode is not available for programming business objects or pages.

Using an external editor   Top of page

If you wish to develop your programming logic outside the SilverStream IDE, the Programming Editor provides an interface that allows you to work in an external Java development environment. Through this interface you can:

This section explains how to use this interface, first by specifying an external editor and then by launching the tool and exchanging information with it.

If you want to access SilverStream API packages in your external Java development environment, you must perform some additional steps to configure that environment, as described in the chapter on coding Java for SilverStream applications in the Programmer's Guide.

To specify an external code editor:

  1. In the Main Designer, select Edit>Preferences.

    The Preferences dialog appears.

  2. Select the Editor tab.

  3. Specify the command line needed to invoke your editor in the External editor command line field.

    For example, the command line in this Preferences dialog specifies Borland JBuilder as the external IDE:

Now you are ready to launch and exchange information with your external editor.

To launch and exchange information with the external editor:

  1. In the Programming Editor, select Edit>Launch External Editor or click the Launch External Editor button in the toolbar

    SilverStream opens the .java source file for the class (page, form, or business object) in the specified editor.

  2. Modify your code using the external editor.

  3. Save your changes in the external editor.

  4. Choose one of these actions:

    To

    Do this

    Incorporate the edits you made externally

    • Select Edit>Retrieve Text from External Editor or click the Restore Data from External Editor button in the toolbar:

      SilverStream reads in the changes made externally and updates the Programming Editor. The connection with the external editor is broken.

      You will be prompted if the code in the external editor has not been saved.

    • To continue editing externally, select Edit>Launch External Editor.

    Cancel any changes you made externally

    • Select Edit>Cancel External Edit or click the Cancel External Edit button in the toolbar:

      SilverStream breaks the connection with the external editor and does not update the Programming Editor with any changes made externally.

Specifying single-method view or whole-file view   Top of page

The SilverStream Programming Editor gives you the option of writing and editing your Java code in two different ways:

Initially, the Programming Editor opens in single-method view. Once you have used the Programming Editor, it will open the next time in the mode that was active during your last editing session.

To navigate from one method to another in single-method view, select a callable object from the Object dropdown list and an associated event from the Event dropdown list, as described in The Programming Editor dialog in Java mode. When you select an event, the Programming Editor either takes you to the existing event handler or creates the method signature for a new event handler.

To use whole-file view:

  1. Click the Switch to whole file view icon:

    The text area adjusts to display the entire class definition for the page, form, or business object. The cursor appears in the same method, declaration statement, or import statement that was displayed in single-method view before you switched modes.

    Here is an example of a whole-file view of the class definition for a form. The cursor appears in the event handler method handle_New_actionPerformed(), which is displayed in the context of the entire class definition:

    You now have access to all components of the class definition in the scrollable text area.

    CAUTION!   Be careful when working in whole-file view. It is easy to make cut-and-paste errors inadvertently and end up with invalid code. In particular, heed the warning comments that SilverStream provides about not editing definitions that are generated automatically.

To use single-method view:

  1. Click the Switch to single method view icon:

    The text area displays the method, declaration statement, or import statement where the cursor appeared before you switched modes.

    The following example shows the same class definition in single-method view. Here the event handler method handle_New_actionPerformed() appears by itself in the text area:

Editing package and class names   Top of page

When developing a business object in whole-file view, you can edit the package name--the first line of the file--and the class name for the business object. When you save the object, SilverStream automatically saves the newly named class in the newly named package.

When developing a form or a page in whole-file view, do not edit the package name or class name. Any changes you make to these names will be overridden by SilverStream when you save the object--because forms must reside in com.sssw.gen.forms and pages must reside in com.sssw.gen.pages.

You do not have access to package names and class names in single-method view.

Programming in Java mode   Top of page

Programming in Java mode simply means that you use the SilverStream Programming Editor to write, compile, and test your own Java source code. In Java mode you have access to the full Java language, Java APIs, and the SilverStream API.

The Programming Editor works in Java mode for developing application logic in pages and business objects. For forms, the Programming Editor gives you two options: Programming in Java mode or with Simple Actions, a wizard interface for automatically generating Java code for prepackaged actions. To switch from Simple Actions mode to Java mode in the Form Designer, click the Switch to Java code button that appears at the top of the Programming Editor window:

When you first start up the Programming Editor in the Form Designer, it opens in Simple Actions mode.

This section describes how to use the Programming Editor to develop your own Java code in the Page Designer, Form Designer, and Business Object Designer. It includes the following topics:

    For information about using Simple Actions instead of Java mode in forms, see Programming with Simple Actions.

Configuring the Form Designer Wizard to generate Java code   Top of page

To program in Java mode, you must configure the Form Designer Wizard to generate Java code by setting an Editor preference in the Main Designer.

To configure the Form Designer Wizard to generate Java code:

  1. Select Edit>Preferences in the Main Designer.

  2. Select the Editor tab.

  3. Select the Java Code radio button.

The Programming Editor dialog in Java mode   Top of page

The Programming Editor in Java mode gives you access to the Java APIs and SilverStream API, and provides information about objects, methods, and events to help you develop your Java code and navigate your class definition.

Here is a sample Programming Editor dialog invoked from the Form Designer in Java mode:

The dialog consists of the following interactive controls:

You can access the Object and Event lists in both single-method view and whole-file view. When definitions already exist for objects and events, they appear in bold in the Object and Event lists.

The Programming Editor controls facilitate the process of Java coding by helping you navigate your class definition and select from lists of allowable events and methods for objects defined in your class or callable from your class.

To navigate the Java class file:

  1. Select an object from the Object list.

    The Event list updates its list of choices based on what you select in Object list, as follows:

    If you select

    Event list displays

    An object

    A list of events associated with the object selected

    General

    "Imports", "Declarations", and methods

  2. Select an item from the Event list.

    The Programming Editor updates the Code Editor window based on what you select in Event list, as follows:

    If you select

    Code window displays

    An event

    The event handler code for that event. If the event handler does not already exist, the Programming Editor creates the method signature for you.

    A method

    The code for the method.

    "Imports"

    The section of the Java class definition that contains all import statements.

    "Declarations"

    The section of the Java class definition that contains all declaration statements.

    In the following example, the object btnSave is selected from the Object list. This object represents the Save button that appears on the page pgContacts.html:

    After btnSave is selected, the Event list displays all events associated with the Save button--in this case, the single event pageActionPerformed, as shown:

To invoke methods from callable objects in your class definition:

  1. Click in the Code editor window where you want to insert the method call.

  2. Select an object from the Callable Objects pane.

    The Methods pane displays all methods that can be called on the selected object.

  3. Select a method in the Methods pane, as follows:

    To

    Do this

    View the method syntax in the Status bar

    Single-click the method you want

    Insert the method call in the Code editor window

    Double-click the method you want

  4. Supply any required parameters to complete the method call.

To get help on an object or method:

  1. Select an object from the Callable Objects pane or select a method from the Methods pane.

  2. Press F1.

    SilverStream help opens in your browser, displaying information about the object or method you selected.

Writing event-triggered code   Top of page

Events are used to notify an application when user interaction has occurred, such as pressing a button or loading a page in a browser. To specify how your application responds to these events, you must define methods called event handlers.

The Programming Editor facilitates the process of writing event-triggered code by showing you the list of events that can be associated with each callable object in your class definition. See The Programming Editor dialog in Java mode for more information about using object and event lists.

To write Java code for a specific event:

  1. Choose an object from the Object dropdown list.

    The Event list is updated to display the list of events associated with the selected object.

  2. Select the event of interest from the Event list.

    The Programming Editor inserts a signature for the appropriate event handler method in the Code Editor window.

    In the following example, the Programming Editor automatically adds the signature for the event handler handle_chkUseTransactions_valueChanged()--a method that will respond to the user action of checking or unchecking a check box. Note that the check box chkUseTransactions is selected in the Object list and the event valueChanged is selected in the Event list:

  3. Write the event handler by adding your own Java code.

    NOTE   You can invoke methods on callable objects in your class definition as described in The Programming Editor dialog in Java mode, and you can write your own methods as described in Adding your own custom methods.

    For more information about events, see About Properties and Events in the Property and Event Reference.

Adding your own custom methods   Top of page

You can write your own methods for a form, page, or business object. These custom methods might support a specific business function or act as a module of reusable business logic shared by other applications.

You can call your custom methods from anywhere in the form, page, or business object. Depending on the visibility you specify for the method, you can call the method from other objects as well.

There are several ways to define your own methods:

To use the Add New Method Wizard:

  1. Select Tools>Add New Method.

    The Add New Method Wizard opens:

  2. Specify the following information for the new method:

    Field

    Specifies

    Method name

    Name of the custom method.

    The name can contain only letters, numbers, and the underscore character, and cannot start with a number.

    SilverStream suggests that you follow the standard Java naming convention: begin method names with an initial lowercase letter and then initial cap each word for the rest of the name, as in these examples: closeEmployeeForm or deleteRecords. Only class names should start with an initial uppercase letter.

    Visibility

    Where the method can be called:

    • Public: The method can be called from anywhere.

    • Private: The method can be called only from within the defining class--that is, from within the page, form, or business object.

    • Protected: The method can be called from the defining class, subclasses of the defining class, and all classes in the package containing the defining class.

    • Package: The method can be called from the defining class and any other class in the same package, as follows:

      · For pages, from any page in the database

      · For forms, from any form in the database

      · For business objects, from any business object in the same package only

    Return type

    Data type of the value the method returns.

    For example, if the method calculates an Integer value, then you typically want the return type to be Integer. The return type void means the method doesn't return a value.

    # of parameters

    Number of parameters you want to pass to the method.

    If you specify a number greater than zero, the wizard prompts for the name and data type of each parameter.

    Throws exception

    Whether the method throws one or more exceptions in error conditions.

    If you select this box, you are prompted to specify the exceptions that the method can throw.

    Once you have specified the necessary information, the wizard adds the method definition. The custom method's definition is available in the General section of the Programming Editor.

  3. Write code for the method in the Programming Editor.

Deleting and modifying custom methods

When you work in whole-file view, you can delete custom methods and modify their signatures directly in the Code Editor window. In single-method view, you must use commands from the Tools menu, as described in the procedures in this section.

For more information about code file views, see Specifying single-method view or whole-file view.

To delete a custom method in single-method view:

  1. Select the method from the General section by:

  2. Select Tools>Delete Method.

  3. Confirm the deletion.

To modify the signature of a custom method in single-method view:

  1. Select the method from the General section by:

  2. Choose Tools>Edit Method.

    The Edit Method dialog opens, allowing you to change method name, visibility, return type, parameters, and exceptions.

Adding Java interfaces   Top of page

The Programming Editor lets you add Java interfaces to the class definitions for your pages, forms, and business objects.

To add a Java interface:

  1. Make sure that you add the appropriate JAR files for the interfaces you plan to add to your class definition. Follow these steps:

  2. Choose File>Java Interfaces.

    The Java Interfaces dialog appears.

  3. Follow one of these procedures:

    To

    Do this

    Add an interface

    1. Click Add.

      The Add Interface dialog opens.

    2. Enter the interface name either by typing it directly or selecting it from the dropdown list.

    3. Select the Create stubs for interface methods checkbox if you want the Programming Editor to create the method stubs automatically.

    4. Click OK.

    Edit an interface

    1. Select an interface and click Edit.

      The Edit Interface dialog opens displaying the name of the selected interface.

    2. Edit the interface by changing the name and deciding whether to create stubs for interface methods.

    3. Click OK.

    Delete an interface

    1. Select an interface and click Delete.

    2. Click OK.

    NOTE   You must delete method stubs manually.

  4. Click OK.

Handling exceptions   Top of page

The Programming Editor prompts you to handle exceptions in your Java code by flagging the following situations at compile time:

Overriding methods for business objects   Top of page

When you override a method, you replace a method in a superclass with a method in a subclass. This capability allows a subclass to inherit most of its behavior from its superclass--and therefore reuse existing code--yet override specific behavior as needed for its own unique requirements.

There are rules associated with overriding methods. For example, the new method must use the same name, return type, and parameters as the method it overrides. The parameters must match in number, type, and order.

The Programming Editor helps you override methods in your class definitions for business objects by exposing the public and protected methods in the base class. Overriding is available only if you have specified a base class in your business object class definition.

To override methods for business objects:

  1. Select Tools>Override Method.

    The Override Method dialog opens, displaying the public and protected methods in the superclass--the methods that can be overridden.

    NOTE   If there are no public or protected methods in the superclass, no methods will appear in the dialog.

  2. To see methods grouped by superclass, select the Group by class check box.

  3. Select a method and click OK.

    The Programming Editor adds a new method signature to the class definition for your business object. In whole-file view, the method signature appears in the Code Editor window immediately; in single-method view, you can navigate to the new code by selecting General in the Object list and selecting the method in the Event list.

    You can now add programming logic to this method to override its counterpart in the superclass.

Writing Java code using the Action Builder Wizard   Top of page

The Programming Editor allows you to use the Action Builder Wizard to automatically generate Java code for specific actions while you program forms in Java mode. This feature is useful when you cannot remember the syntax for a particular kind of action.

The Action Builder Wizard is not available for pages or business objects.

To code in Java using the Action Builder Wizard:

  1. Position the cursor where you want the Action Builder Wizard to generate Java code.

  2. Select Tools>Insert Action or click the Insert Action button on the toolbar:

    The New Action dialog appears.

  3. Perform one of these actions:

    Select

    What happens

    Next

    Other Action Builder Wizard dialogs appear.

    Step through these dialogs until you specify all required parameters. Then click Finish to generate the Java code in the Code Editor window.

    Finish

    Java code generated by the Action Builder Wizard appears in the Code Editor window.

Navigating the class definition by line number   Top of page

The Programming Editor lets you navigate your class definition by line number. In single-method view, lines are numbered relative to the start of the selected method; in whole-file view, lines are numbered relative to the start of the class definition.

To move to a specific line by number:

  1. Select Edit>Show Line Numbers.

  2. Select Edit>Go To Line.

    The Enter Line Number dialog opens.

  3. Enter a line number and click OK.

    The cursor appears at the beginning of the line you specified.

Finding and replacing text in the class definition   Top of page

You can perform text string searches in your class definition to help you navigate and edit code in the Programming Editor. In single-method view, the search is restricted to code for the selected method; in whole-file view, the search spans the entire class definition.

To find and replace text:

  1. Select Edit>Find and Replace.

    The Find and Replace dialog appears.

  2. Fill in the fields to provide a target string and (optionally) a replacement string and criteria for matching.

  3. Click the appropriate find or replace buttons.

  4. When you have completed your search, click Done.

    NOTE   After dismissing the dialog, you can find the next instance of the target string by selecting Edit>Find Again.

Programming with Simple Actions   Top of page

Simple Actions mode provides a wizard interface that translates predefined actions into Java code. This feature is designed as a shortcut for new programmers to generate application logic quickly even if they are not yet conversant with Java syntax, Java APIs, or the SilverStream API.

Simple Actions mode is available only for forms and only in single-method view. The first time you enter the Programming Editor from the Form Designer, the Programming Editor opens in Simple Actions mode. You can also switch to Simple Actions mode from Java mode, but only if you haven't written or edited any code in Java mode. Click the Simple Actions button that appears at the top of the Programming Editor window:

This button is disabled in whole-file view--and also in single-method view if you have written code in Java mode.

Before you use Simple Actions to program new forms, you should learn about how you can configure the Form Designer Wizard and about specific usage restrictions.

This section describes how to use Simple Actions in the Programming Editor to develop forms for your application. It includes the following topics:

Configuring the Form Designer Wizard to generate Simple Actions   Top of page

If you plan to program using Simple Actions, you can configure the Form Designer Wizard to generate Simple Actions by setting an Editor preference in the Main Designer. Otherwise, the Form Designer Wizard generates Java code when you create new forms. In this case, you can still switch to Simple Actions mode selecting single-method view and navigating to a new, empty method that was generated by the wizard. If you add a new method of your own, you will not be able to switch to Simple Actions mode.

    To learn how to navigate your Java class definition, see The Programming Editor dialog in Java mode.

To configure the Form Designer Wizard to generate Simple Actions:

  1. Select Edit>Preferences in the Main Designer.

  2. Select the Editor tab.

  3. Select the Simple actions radio button.

The Programming Editor dialog in Simple Actions mode   Top of page

Here is a sample Programming Editor dialog invoked from the Form Designer in Simple Actions mode:

The dialog consists of the following interactive controls:

The Object and Event lists work the same way as in Java mode, as described in The Programming Editor dialog in Java mode.

The Action Builder, Action Gallery, Branches, and Loops controls allow you to select high-level actions or Java constructs that you want the Programming Editor to convert to Java code under the covers.

For example, if you want to save database changes each time you activate your form, select the formActivate event from the Event list and then choose Save Data from the Action Gallery list. The Programming Editor inserts a simple action in the Code Editor window that saves modifications in the source database table:

When you compile, test, or save Simple Actions, SilverStream internally translates Simple Actions to Java and then compiles the Java. The form behaves consistently, regardless of the mode in which it is developed. You can view the Java code generated for Simple Actions. However, if you edit the code while viewing it in Java mode, you will not be able to return to Simple Actions mode.

To use the Action Builder Wizard in Simple Actions mode:

The Action Builder Wizard is a quick and easy way to create scripts for buttons and fields on a form.

  1. Select Tools>Insert Action or click the Action Builder icon in the toolbar:

    The Action Wizard appears.

  2. Step through the Action Wizard windows, responding to prompts to supply parameter values.

  3. Click Finish to return to the Programming Editor.

    The action is inserted in the Code Editor window.

To view Java code that underlies Simple Actions:

When you finish programming with Simple Actions, you can view the Java code that was generated.

  1. Insert a Simple Action in your form.

    The form must be in Simple Actions mode. Use the Action Builder, Action Gallery, Branches, and Loops controls described earlier in this section.

  2. Click the Switch to Java code button:

    The Java code appears in the Code Editor window.

    After switching to Java mode for this example, the Java code for the Save modified data to the source table action appears in the Code Editor window:

Restrictions on Simple Actions   Top of page

The following restrictions apply to programming with Simple Actions:

Programming a control using Simple Actions   Top of page

There are many actions you can use to program a control on your form.

To program a control using Simple Actions:

  1. If you are creating a new form, follow these steps:

  2. If you plan to work with an existing form, open it in the Form Designer.

  3. Double-click the control you want to program.

    The Programming Editor opens displaying your control in the Object list.

  4. If you are not in single-method view, click the Switch to single method view icon:

  5. If you are not in Simple Actions mode, click the Switch to Simple Actions button:

  6. Select an event from the Event list.

    Pick the event that will fire when the user interacts with the control in the desired fashion.

  7. Click on either the Action Builder or the Action Gallery.

  8. Select an action from one of these lists and step through any dialogs that prompt you to set parameters associated with the action.

    The action you select appears in the Code Editor window.

  9. Compile, save, and test your form.

Creating conditions using Simple Actions   Top of page

You can use Simple Actions as a shortcut for creating conditional statements, which are used to execute code based on a test. Conditional statements must always evaluate to a boolean value (true or false).

To create a conditional statement using Simple Actions:

  1. Create a new form or open an existing form in the Form Designer.

  2. Access the Programming Editor by performing one of these actions:

  3. If you are not in single-method view, click the Switch to single method view icon:

  4. If you are not in Simple Actions mode, click the Switch to Simple Actions button:

  5. Move to the location in your form class definition where you want to insert the conditional statement.

    If you want to insert a conditional statement in existing code, you can navigate to that location using the Object and Event lists, as described in The Programming Editor dialog in Java mode.

  6. Select either the Action Builder icon or the Branches icon from the gallery and follow the appropriate steps:

    If you select

    Do this

    Action Builder

    1. Expand the Conditionals and Looping list in the New Actions dialog.

    2. Select a conditional statement and click Next.

    Branches

    Select a conditional statement from the popup list.

    The Expression Builder appears.

  7. Select the variables and functions you need to create your expression.

    NOTE   You do not have to select a conditional operator in the Expression Builder.

  8. For example, to specify a condition that flags null strings in a field, enter an expression similar to the following:

      value = "" 
    
  9. Click Finish.

    The conditional statement you created appears in the Programming Editor window in blue, as in this example:

    NOTE   This example also contains a Simple Action that displays a message if the condition is true. This action--Show a Message--was inserted from the Other Actions list in the Action Builder Wizard.

  10. Compile, save, and test your form.

Displaying a form as a dialog using Simple Actions   Top of page

To show a form in a dialog:

  1. Create a new form or open an existing form in the Form Designer.

  2. Access the Programming Editor by performing one of these actions:

  3. Select the form from the Object list and an associated event from the Event list.

  4. Select the Action Builder icon.

    The Action Builder Wizard appears.

  5. Expand the Other Actions list, select Show a Form in a dialog, and click Next.

    A dialog appears that prompts you to select the form and enter a caption.

  6. Step through the Action Wizard windows, filling in fields as required.

  7. Select Finish to return to the Programming Editor.

    The Simple Action you just created appears in the Code Editor window.

  8. Compile, save, and test your form.

Checking Java syntax   Top of page

You can check your Java code for errors at any time--in Java mode and Simple Actions mode, in single-method view and whole-file view.

You can specify which compiler to use and whether to include debugging information by setting Compiler preferences in the Main Designer.

To check syntax:

  1. Select File>Check Syntax or click the Check Syntax icon:

    SilverStream compiles the code. Any errors are listed one at a time in a panel that appears at the bottom of the Programming Editor window between the Code Editor window and Status bar. The line of code containing the error appears in red in the Programming Editor window.

  2. If more than one error is detected, click the Next error button in the error message panel to view it.

Saving objects   Top of page

You can save pages, forms, or business objects from the Programming Editor at any time--in Java mode and Simple Actions mode, in single-method view and whole-file view.

By default, the Programming Editor compiles forms, pages, and business objects before saving them. For business objects, you can elect to save without compiling.

To save a form or page after compiling:

To save a business object after compiling:

To save a business object without compiling:

Testing your code   Top of page

You can test your class definitions for pages and forms from the Programming Editor.

To test pages and forms from the Programming Editor:

  1. Make sure your code compiles without error.

  2. Select File>Run Test or click the Enter Test Mode button in the Programming Editor toolbar:

    Pages are launched in a browser and forms are invoked in SilverJRunner.

Printing your code listing   Top of page

You can print your Java code listing from the Programming Editor in the Form Designer, Page Designer, and Business Object Designer. You can print your code either as monochrome output or as a chroma-coded listing on a color printer. A chroma-coded listing displays the colors SilverStream uses to highlight important code elements, as described in Chroma-coded programming environment.

To print from the Code Editor window:

  1. Select File>Print.

    The Page Setup window appears.

  2. Keep the defaults or edit any settings as appropriate, then click OK.

    The Print window appears.

  3. Override any default settings as necessary, then click OK.

Debugging your code   Top of page

You can launch the SilverStream Debugger from the Programming Editor in the Page Designer, Form Designer, and Business Object Designer.

To start the Debugger:

  1. Start the SilverStream server for debugging.

  2. Configure the Main Designer to record debugging information in your compiled Java code.

  3. Set breakpoints in the Programming Editor and start your application.

    To learn how to perform these procedures and use the Debugger for your specific application needs, see SilverStream Debugger.

Customizing the Programming Editor   Top of page

In the Main Designer, you can specify the following display parameters and behaviors for the Programming Editor:

For more information, see Setting preferences in Main Designer.

Programming Editor keyboard shortcuts   Top of page

Use these keyboard shortcuts.

Keystroke

Description

Ctrl+S

Save

Ctrl+Z

Undo

Ctrl+U

Undo all

Ctrl+Y

Redo

Ctrl+X

Cut

Ctrl+C

Copy

Ctrl+V

Paste

Ctrl+G

Go to line number

Ctrl+F

Find/Replace

Ctrl+K

Check syntax

F1

Open Help

F3

Find again

F9

Toggle breakpoint






Copyright © 2000, SilverStream Software, Inc. All rights reserved.