How to use the built in JSP Eclipse Editor and a custom tld file to get code completion in Eclipse 3.4+ and Tapestry5

Have you been looking for a method to get "code" completion while editing *.tml files in Eclipse? This method uses a TLD file with the Eclipse JSP editor to give you exactly that.

Note: an promising alternate approach is being developed at http://code.google.com/p/tapestrytools/

The following are available from GitHub:

(Older versions are available here)

All steps were performed on Eclipse 3.4. (This will not work on Eclipse 3.3. The JSP Editor by default does not appear to easily support the xmlns declarations.)

TLD files have been generated by tapestry-tldgen Maven plugin (http://github.com/exanpe/tapestry-tldgen). You can also use this plugin to generate TLD associated to your own Tapestry 5 components library. Please have a look at http://exanpe.free.fr/tapestry-tldgen/ for advanced information and usage explanation.

Regardless, this really helps out coupling Eclipse and Tapestry 5.

#-- Installing and configuring Eclipse for Tapestry 5 tml file editing.

  1. Associate any *.tml file with the JSP Editor.
    • Window -> Preferences -> General -> Content Types
    • Expand Text
    • Select JSP
    • Click "Add"
    • Enter *.tml
    • Apply and Save.

2. Install the TLD associated to your Tapestry 5 version ( Tag Library Definition ) and associate it with the default Tapesty 5 Name Space.

  • Save the TLD project file to a static location on your system. This will be a known location that will not be removed.
  • Window -> Preferences -> XML -> XML Catalog
  • Under "User Specified Entries", create a new association by clicking "Add"
  • Click on the "File" Icon to browse to the saved TLD file, and select it.
  • Leave the key type as : "Public ID"
  • Set the key field to: http://tapestry.apache.org/schema/tapestry_5_0_0.xsd for 5.0 Version and http://tapestry.apache.org/schema/tapestry_5_1_0.xsd for others
  • Save the entry.

3. Install the default *.tml template in the JSP template provider:

  • Window -> Preferences -> Web -> JSP Files -> Editor -> Templates
  • Click the "import" button and browse to the provided file in this project: "NewTMLTemplate.xml"
  • Selecting it will import the template.
  • Click "Apply", "Save"

Once all steps are completed, you can create a new *.tml file by creating a new JSP File, and selecting the TML Template.

In any location of the html block, you can get Tapestry Component completion now by starting a new tag with:

  • <t:

and hitting ctrl-space. A list of available components will be provided along with standard Eclipse help dialogues.

  • No labels