[opencms-dev] Adding a custom form field to TemplateOne (OpenCms 6.2.2)

Ellery Crane ecrane.tech at gmail.com
Mon Apr 14 18:05:32 CEST 2008


I am trying to add a custom form field to TemplateOne in OpenCms version
6.2.2. I have not found any documentation anywhere as to how to do this; I
am working off of the existing instructions and documentation of the person
who developed the custom form field code. I have three files:

CmsTextLabelField.class - A compiled class file of the java source for the
new form field, which extends A_CmsField.

inputfield.xsd - A modified version of the existing file which adds the form
field to the FieldType SelectorWidget configuration value.

custom_form_fields.properties - A single line of text which maps the new
form field's label (used in inputfield.xsd) to the full class name.  It
consists of this line:
FIELDS=textLabel:org.opencms.frontend.templateone.form.CmsTextLabelField

The instructions I have say the following:

inputfield.xsd goes into:
/system/modules/org.opencms.frontend.templateone.form/schemas/

CmsTextLabelField.class goes into:
/system/modules/org.opencms.frontend.templateone.form/classes/org/opencms/frontend/templateone/form/


custom_form_fields.properties goes into:
/system/modules/org.opencms.frontend.templateone.form/classes/

When I put these files in these directories (within the workspace), I
successfully see a new field in the select box when editing a form. It does
not have the proper label, however; it shows as:
??? form.field.type.textLabel ???

When I  save the form and try to view it, I get a null pointer exception:

10 Apr 2008 14:10:08,156 ERROR [mplateone.form.CmsFieldFactory: 199] Unable
to create form field class instance for type textLabel!
java.lang.NullPointerException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at
org.opencms.frontend.templateone.form.CmsFieldFactory.getField(CmsFieldFactory.java:195)
    at
org.opencms.frontend.templateone.form.CmsForm.initInputFields(CmsForm.java:1260)
    at org.opencms.frontend.templateone.form.CmsForm.init(CmsForm.java:627)
    at
org.opencms.frontend.templateone.form.CmsForm.<init>(CmsForm.java:261)
    at
org.opencms.frontend.templateone.form.CmsFormHandler.init(CmsFormHandler.java:294)
    at
org.opencms.frontend.templateone.form.CmsFormHandler.<init>(CmsFormHandler.java:124)
    at
org.apache.jsp.WEB_002dINF.jsp.offline.system.modules.org_opencms_frontend_templateone_form.pages.form_html_jsp._jspService(form_html_jsp.java:57)
    ...

Looking through the source of both CmsForm and CmsFieldFactory for the
version 6.2.2 of OpenCms, it appears that it is trying to instantiate the
field by calling Class.forName() on the string "textLabel" rather than the
full name of the class file (as specified in custom_form_field.properties).
How do I fix this? How do I make OpenCms read in the properties file? And,
assuming I get that running, is this the standard way to add new form
fields?  Is there any documentation on this process available somewhere?  I
am an experienced Java developer, but I'm a newbie to OpenCms. Any help
would be appreciated.

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080414/9a7238fc/attachment.htm>


More information about the opencms-dev mailing list