When you create a Java control, you can define properties and attributes that a developer can set to elicit specific behavior when using the control. This topic lists the procedure for defining and handling properties and their attributes:
Note. For an introduction to building Java controls, including specifying properties, see Tutorial: Java Control.
Typically, this is the same folder that contains the JCS for which the annotations will apply.
This is typically a name that associates the file with the control. For example, if your control source file is called MyControl.jcs, you might call the annotations file MyControlAnnotations.xml.
WebLogic Workshop will display the contents of the new file, which includes template XML source code.
The template in the new file is a starting place. It defines a sample-control-tag property that would be exposed on a control instance (that is, for the control as a whole). It also defines a sample-method-tag property that would be exposed on a control method.
The sample-control-tag property defines a sample-attr attribute whose type is boolean. This attribute is marked as not being "required," which means that a developer using the control would not need to set the attribute explicitly. As a result, the sample-attr attribute specifies a default value of "false" to use if the developer does not set their own value.
See Control Property Schema Reference for a complete list of the XML tags you can use to define Java control properties.
The control's name should be displayed just beneath the Property Editor tab.
This should be a relative path. If your XML file is in the same folder as the JCS, you need only type the XML file name. If the XML is in a subfolder, you must include that folder's name.
You can now write code that enables the control to retrieve values set by a developer using the control.
For example, if you had used the sample-control-tag property and sample-attr attribute defined by the annotation template, you might use the following code to simply return the attribute's value from a method on the control called getSampleAttr:
/** @common:context */ ControlContext context; /** * @common:operation */ public boolean getSampleAttr() { /* * Call the getControlAttribute method, passing a string with the name of the * property as its annotation appears in source code, along with the name of the * attribute whose value should be retrieved. */ String sampleAttrValue = context.getControlAttribute("jc:sample-control-tag", "sample-attr"); /* Because the method returns a String, convert the value to a boolean. */ boolean booleanValue = new Boolean(sampleAttrValue).booleanValue(); return booleanValue; }
For a sample that uses control properties, see the POVerify sample included in the SamplesApp application installed with WebLogic Workshop.