Eclipse Hinting code on JSP with custom tags (taglib)

I am developing a JSP tag that has an attribute that works with a set of possible values.
I do not need to force these values, but I would like my IDE (Eclipse) to do some code hints or autocomplete.

Suppose such a tag <mytag:sometag someattribute="value" />.

The attribute someattributecan have any value (note that I did not need to use it), but I would like to offer you the following list of values: ValueA, ValueBandValueC

Nitin Dahyabhai on the Eclipse community forums suggested writing a plugin based on org.eclipse.wst.xml.core.modelQueryExtensionsor creating templates with values.

The problem with templates is that I have hundreds of possible values, and I have several tags.
The problem with writing a plugin is that I do not have the time or knowledge to do this.

Is there any other way to do this?

+3
source share
1 answer

In case you finish writing the Eclipse extension for modelQueryExtensions, it should be as simple as:

Create a new plugin: com.my.tagliband add it to plugin.xml:

<extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
  <modelQueryExtension
    class="com.my.taglib.MyTaglibModelQueryExtension"
    contentType="org.eclipse.wst.html.core.htmlsource">
  </modelQueryExtension>
</extension>

Then we implement the com.my.taglib.MyTaglibModelQueryExtensionclass:

public class MyTaglibModelQueryExtension extends ModelQueryExtension {

    public String[] getAttributeValues(Element e, String namespace, String name) {
        // See XSDModelQueryExtension for an example implementation of this...
    }
}
+1
source

All Articles