< 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.
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.
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 ExceptionsException 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 > |