Custom Widgets

(Difference between revisions)
Jump to: navigation, search
m (fixed typo)
m (Explained what FQCN stands for, since it is not obvious to everyone.)
Line 2: Line 2:
 
When creating [[XMLContent| XML content]] the input methods available with the [[XMLContent#Widgets | existing widget types]] might not suffice for the desired content.  
 
When creating [[XMLContent| XML content]] the input methods available with the [[XMLContent#Widgets | existing widget types]] might not suffice for the desired content.  
  
By subclassing <tt>A_CmsWidget</tt> you can easily create your own widget types. In order to make use of it it can be referenced from XSD files by its FQCN or by a alias name for the class in <tt>opencms-vfs.xml</tt>.
+
By subclassing <tt>A_CmsWidget</tt> you can easily create your own widget types. In order to make use of it it can be referenced from XSD files by its Fully Qualified Class Name (FQCN) or by a alias name for the class in <tt>opencms-vfs.xml</tt>.
  
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?xml version="1.0" encoding="UTF-8"?>

Revision as of 14:21, 23 November 2006

Custom Widgets

When creating XML content the input methods available with the existing widget types might not suffice for the desired content.

By subclassing A_CmsWidget you can easily create your own widget types. In order to make use of it it can be referenced from XSD files by its Fully Qualified Class Name (FQCN) or by a alias name for the class in opencms-vfs.xml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-vfs.dtd">
<opencms>
  <vfs>
     ...
     <xmlcontent>
       ...
       <widgets>
         ...
         <widget class="com.acme.widgets.AcmeEmployeeSelectionWidget"
           alias="AcmeEmployeeSelectionWidget" />
       </widgets>
       ...
     </xmlcontent>
  </vfs>
</opencms>

You need to restart OpenCms to activate the change. If such an alias has been defined, the widget can be used as shown in the next listing.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified">
  <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
  ...
  ... your complexType definitions which include an element Employee
  ...
   <xsd:annotation>
     <xsd:appinfo>
       <layouts>
         <layout element="Employee" widget="AcmeEmployeeSelectionWidget" />
       </layouts>
     </xsd:appinfo>
  </xsd:annotation> 
</xsd:schema>

Custom Data Types

This section is still to be written.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox