| SimpleClientServer |
Building the SimpleClientServer Components |
The purpose of this sample is to illustrate how a set of related components can be packaged together (along with icons and documentation) in a single JAR. A single batch file is used to refresh the documentation (built using JavaDoc, or -- in this case -- JSBDoc for JavaScript Beans), and to place everything into a single JAR with a manifest that notes which files are Components:
Manifest-Version: 1.0 Name: netscape/samples/simple/LayerController.jsb Java-Bean: True Name: netscape/samples/simple/ServerEcho.jsb Java-Bean: True
Individual components can also specify icons to be displayed in the design-time
environment. For example, the following line in netscape/samples/simple/LayerController.jsb
associates "n_s_s_LayerController32.gif" as the large (32x32) icon to be displayed,
and "n_s_s_LayerController.gif" / "n_s_s_LayerControllerSelected.gif" as the small
(16x16) regular and selected icons:
/** * n_s_s_ stands for netscape/samples/simple... * allows icon to sit in root of jar * while providing reasonable namespace-collision protection */ <JSB_ICON ICONNAME="n_s_s_LayerController">
ICONNAME="n_s_s_LayerController" | ||
---|---|---|
![]() |
![]() |
![]() |
n_s_s_LayerController32.gif | n_s_s_LayerController.gif | n_s_s_LayerControllerSelected.gif |
In addition, Components allow the specification of a Help URL (see CustomProperty for an example of a Java component with a BeanInfo that specifies a Help URL). The following JSB Descriptor in the LayerController component provides a Help URL (which, in this case, is simply the automatically generated documentation created by the JSBDoc tool).
/** * The LayerController can show and hide a layer, * and supports multiple layer controller instances per page... */ <JSB_DESCRIPTOR NAME="netscape.samples.simple.LayerController" DISPLAYNAME="Layer Controller" HELP_URL="netscape/samples/simple/LayerController_jsb.html">
Since the component is packaged in a JAR file, it can include everything the components need, including documentation and icons:
The Component's pieces are assembled into a JAR file using a batch file / shell script (depending on your platform):
Wiring the SimpleClientServer Sample |
Open up Visual JavaScript (VJS). Create a new project named "SimpleClientServer".
Import the jar SimpleClientServer.jar
from the
CDK_INSTALLDIR/samples/SimpleClientServer/
directory to the palette (see
the ShowText example and the VJS documentation
for more information about importing components from JAR files).
netscape/samples/simple/pagelet.html
".
/SimpleClientServer/Page1.html
"). This causes the Form's
Submit to redirect the results to Page1.html within the application after
the application is deployed.
// Add this code to any page with layers window.captureEvents(Event.RESIZE); window.onResize = resetLocation; function resetLocation () { window.location.reload(); }
project
directory under CDKINSTALL/samples/SimpleClientServer
Congratulations! This example shows how easy it is to build a client / server Web Application using pre-built (or custom) re-usable components!.
Note: For more sample components that use Layers, take a look at the Dialog Widget example. |