Enabling Typeahead Content Assist in Themes and Using The Eclipse Snippets View

Home » Enabling Typeahead Content Assist in Themes and Using The Eclipse Snippets View

A few weeks ago Naveen Maurya posted a blog about enabling typeahead content assist for faces-config.xml files. The faces-config formatting is standard for JSF so is available from the Sun / Oracle website under the JavaServer Faces DTDs category.

Unfortunately, however, XPages themes resources are not standard. A folder of DTDs has bee provided with Notes / Domino since R6, used for DXL processing. It can be found in <notes>xmlschemas or <domino>xmlschemas. However, because this is only used for DXL manipulation, even domino_9_0.dtd does not include anything for themes. Similarly, I could not find a DTD for themes on the web to link to.

So I’ve put one together (or at least a first version). I’m not an expert on DTD files, so it may not be complete, there may be attributes or elements missing. There may also be attributes specified that you would want to use as elements, but which have not been defined as elements as well. And vice versa.

For those not au fait with DTD terminology, elements are XML objects either at the top level or as a child of another element, e.g. “theme”, “resource”, “control”. Attributes are, like you’re familiar with in XPages and Custom Controls, properties of the relevant XML element but are defined within the parent element rather than as a child. So “extends” is an attribute of “theme” because the syntax is <theme extends="oneuiv2">. So a property can be both an attribute and an element, sometimes defined using the property="value" syntax, sometimes defined as a child element.

Enabling typeahead is a pretty straightforward, as Naveen described. You just define a doctype and point to the DTD file. If the DTD is accessible and properly formatted, content assist will work. However, when I came to preview the XPage, I got an error because the file was not accessible from our development server. After lots of trial and an equally large amount of error, I chose a twofold approach: use GitHub to store the file and reference the URL directly when using on a server that has access to the internet; store the file locally when developing on my local server. Check out the readme file for details on how to implement it in a theme resource.

But who wants to go to the web, then copy and paste that code every time you want to use it? Fortunately Eclipse gives Domino Designer a shortcut: the Snippets view. This can be enabled by going to Window > Show Eclipse Views > Other. Use the filter textbox to filter for “Snippets” and add the view. Then copy the code, right-click in the Snippets view and select Paste as Snippet… or Paste. Snippets can be categorised by creating new categories. You can define a name and description, then the Template Pattern is the content to be inserted. The snippet can then be dragged and dropped into the Theme or you can right-click it and select Insert to insert it wherever the cursor is.

Snippets

And the Snippets view can be used in any of the standard Eclipse-based editors as well, so all except traditional design elements. Of course you’ll want to backup your snippets. The key is in the above screenshot. That dialog can also be accessed by right-clicking the Snippets view and selecting Customize…. You’ll see there’s an Export button. If you select a category, the Export button is activated, allowing you to export all snippets in that category.

 

1 thought on “Enabling Typeahead Content Assist in Themes and Using The Eclipse Snippets View”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top