Table of Contents Markup Tutorial Interfacing with Java™ Web Services

Since all Java™ beans, by definition, have a default public constructor you can use an object element to realize any Java bean. If the bean has a property that you can describe in markup understood by eNode Object Realizer, you can automatically set that property for the bean simply by inserting a property element as a child of the object element, and setting the property element’s key attribute equal to the property name.

The property value may be specified inline within the property element as its element content. Alternatively, you may use the href attribute from the XLink namespace to associate a remote resource with the property element. In the former case, the property value’s type is determined by the element type of the property element’s content. In the latter, it is always treated as a generic Object.

By the way, remote does not mean that the resource has to be in a different XML document on a far-away host (although it could be). It simply means that the referenced resource is described outside the property element, and could very well be in the same document.

Bean Properties

The following example realizes a rudimentary object inspector bean called com.enode.xalt.examples.Inspector. The bean has two properties called viewer and target, that are part of the public interface of the bean. The properties are automatically set — from the markup itself — by inserting suitable child elements into the element representing the Inspector bean.

Make this object in eNode Sandbox. The result should be similar to the following:

The Example Explained

When the Inspector bean’s target property is set, the bean gathers intimate details about the target, and provides a report to the text component that is the bean’s viewer property.

Further down, the scrollPane element has a textAreaRef element that refers to the textArea element whose id attribute is equal to myTextArea. As a result, they both share the same text area at the core. When the scroll pane is shown, the text area within it should contain revealing details about the core of the label element whose property attribute is equal to target. If you scroll to the bottom of the text area, then about ten lines from the bottom, you should see the title of the label, and descriptive information about the icon.

Now, try to inspect the following targets (one at a time, of course):

<property key="target">
    <object class="javax.swing.JLabel"/>
</property>

<property key="target">
    <color value="textHighlight"/>
</property>

<property key="target">
    <fontRef xlink:href="#myFont"/>
</property>

or even the viewer itself...

<property key="target">
    <textAreaRef xlink:href="#myTextArea"/>
</property>

The Inspector Bean

The code for the Inspector bean is shown below.


Copyright © 2002 eNode, Inc. All Rights Reserved.