Using Existing Controls

 <  Day Day Up  >  

Controls are added to Page Flows or other controls by drag and drop or via the Data Palette. Controls can be local or nonlocal. Local controls are contained within projects in the same application. Nonlocal controls are contained in JAR files within the Library folder. Local controls can be dragged and dropped into a Page Flow or another control. Nonlocal controls must be added via the Data Palette. Figure 6.4 shows selecting a new control, right-clicking, and pointing to Add Control, which displays a list of all known controls. Simply select the control you'd like to add, and an instance is added to your control or Page Flow.

Figure 6.4. Adding a control using the Data Palette.

graphics/06fig04.gif

If the control is local to the project ”that is, contained within the application project ”you can drag it into the right pane of a control or the Action View of a Page Flow to add an instance. Inserted controls are annotated with an @common:control annotation. After they're added, local and nonlocal controls look no different from a traditional variable, including added package statements, with the exception of this annotation:

 /**  * @common:control */ private controls.Sample  sample  ; 

This code shows a control in the controls package of type Sample . The control variable name sample can be changed to whatever's required.

METHOD NAME COMPLETION

Figure 6.5 shows an ease-of-use feature: method name completion. Simply enter the name of a variable followed by a dot ( . ), and all its public data members and methods are shown. Partially typing a name shows only those members and methods that match the portion of the entered text. You can use the arrow keys to scroll up and down the list and then press the Tab key to enter the complete name.

Figure 6.5. Using method name completion.

graphics/06fig05.gif


You call a control's methods exactly as you would any other Java class ”capturing the method's return value and dealing with exceptions as the method requires.

Handling Exceptions

Exception handling with controls is no different than with traditional Java classes. Try , catch , throw , and finally are all supported in the Workshop framework. Even if a control developer didn't declare any exceptions, the Workshop framework might still throw com.bea.control.ControlException , which can and should be caught. Exception handling within controls and the handling of ControlException s are important because the calling class likely knows nothing of the framework or the specifics of the exception being thrown.

 <  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