简体   繁体   中英

Eclipse Code Hinting on JSP with Custom Tags (taglib)

I'm developing a JSP tag that have an attribute that works with a set of possible values.
I don't need to enforce this values, but I would like my IDE ( Eclipse ) do some code hinting or auto-completion.

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

The attribute someattribute can have any value (remember, I don't need to enforce), but I would like it to suggest you the following list of values: ValueA , ValueB and ValueC

Nitin Dahyabhai at the Eclipse Community Forums suggested writing a plugin based on org.eclipse.wst.xml.core.modelQueryExtensions or create templates with the values.

The problem with templates is that I have hundreds of possible values and I have multiple tags.
The problem with writing a plugin is that I haven't time or knowledge to do it.

Is there another way to do it?

In case you end up with writing Eclipse extension for modelQueryExtensions, that should be as simple as:

Create new plug-in: com.my.taglib , and add to its 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 implement com.my.taglib.MyTaglibModelQueryExtension class:

public class MyTaglibModelQueryExtension extends ModelQueryExtension {

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM