Code-level Development

 <  Day Day Up  >  

As mentioned previously, Workshop offers two-way editing between Design View and Source View so that you can switch back and forth between these tools as you define items and operations and then fine-tune them.

Accessing the Source View Pane

There are multiple ways to access the Source View window. The methods that are particularly useful not only open the window, but also zero in on the code you're currently working on. For example, double-clicking an item in the Document Structure pane opens the Source View with the particular method, variable declaration, or element highlighted.

Double-clicking any item in the Design View has a similar but slightly more complex behavior. If the code is directly part of the item being edited, the Source View is opened with the corresponding method highlighted. If the code belongs to another file, however, double-clicking the item opens the other file first in Design View. From there, you can switch to the Source View by double-clicking the item of interest in the new Edit pane.

When the code is completely implemented by Workshop and cannot be edited, however, double-clicking the item has no effect. This is the case with the Timer control.

To demonstrate these concepts, display the Controller.jpf file in the Flow View pane, and double-click the begin action. Because the code behind this item is located in the Controller.jpf file, the Source View opens with the protected begin method declaration highlighted.

Now return to the Flow View pane and double-click the index.jsp page. Because the JSP code is defined in a second file, the Design View opens to display the rendering of the JSP. Double-clicking either line of text opens the Source View with the corresponding HTML element highlighted.

Navigating Through the Code

WebLogic Workshop offers extensive features in the Source View to allow you to sift through a file and quickly get to the code of interest.

Code can be formatted to be easy to view and is colored based on syntax. You can assign separate colors for everything from HTML and XML tags to Java keywords to string literals. Among the other formatting attributes are standard tab sizes, automatic indentation of code within braces, and line numbers that can be toggled on and off.

Workshop also has the capability to expand and contract groups of import statements, class bodies, comments, and method bodies in Java source files. This feature is extremely beneficial when dealing with large code files that scroll off the bottom of the Source View. To expand or minimize a section of code, click the associated + or - symbol in the left margin of the Source View. Figure 2.13 shows an example of minimized and expanded code elements.

Figure 2.13. The + and - symbols in the left margin of the Source View enable you to selectively expand or minimize code elements.

graphics/02fig13.gif

You can tweak all these settings by selecting Tools, IDE Properties from the Workshop menu. In the IDE Properties dialog box that opens, select the Editor folder or one of its subfolders , Printing or Syntax Coloring , to make the changes. Figure 2.14 shows the extensive group of attributes that can be set in the Editor folder of the IDE Properties dialog box.

Figure 2.14. Code View settings can be configured by selecting the Editor folder in the IDE Properties dialog box.

graphics/02fig14.jpg

REMOVING WHITESPACE

When editing JSP files in the Source View pane, you can strip extraneous whitespace (including carriage returns) from the file by right-clicking on the window and selecting Reformat Page from the pop-up menu.


Editing the Code

WebLogic Workshop offers another set of powerful development tools when you start editing source code. As you type any line of code ”whether it's Java, JSP tags, or straight XML ”Workshop continuously scans the line to determine whether it is syntactically valid. If there is an error, the code is underlined in red. When you place the mouse pointer over the line, a tooltip pops up with details on the applicable errors (see Figure 2.15). The important point is that every new line of code is underlined in red until the line is completed.

Figure 2.15. In the Source View, syntax errors are displayed via a tooltip while the code is being typed.

graphics/02fig15.gif

Additional Editing Tools for Java Code

When adding Java import statements or other source code that includes a class name with its package name , Workshop displays a list of applicable packages or classes whenever a package delimiter (that is, a "dot") is typed. You can then double-click any entry in the list to auto-complete the class name. Likewise, when you add a Java method call, after you type the "dot" after the class name, Workshop displays a list of applicable method signatures. You can then double-click any entry in the list to auto-complete the method name. Figure 2.16 shows an example of this pop-up list of method signatures.

Figure 2.16. In the Source View, method calls can be automatically completed by selecting from the pop-up method signature list while the code is being typed.

graphics/02fig16.jpg

Additional Editing Tools for JSP Code

In JSP files, as soon as you try to create a start tag, Workshop displays a list of applicable elements that can be added, including those in JSP tag libraries. Likewise, when you begin to create the end tag, Workshop displays a list of open tags for your selection.

 <  Day Day Up  >  


BEA WebLogic Workshop 8.1 Kick Start
BEA WebLogic Workshop 8.1 Kick Start: Simplifying Java Web Applications and J2EE
ISBN: 0672326221
EAN: 2147483647
Year: 2004
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net