0
votes

I'm developing a JSF component library and I'm writing my components in the same way it's taught in the Java EE 7 Tutorial.

@FacesComponent("DemoMap")
public class MapComponent extends UICommand {
    enum PropertyKeys {
        alt, coords, shape, targetImage;
    }
    public String getAlt() {
        return (String) getStateHelper().eval(PropertyKeys.alt, null);
    }
    public void setAlt(String alt) {
        getStateHelper().put(PropertyKeys.alt, alt);
    }
}

I want to know if there's any way to generate the custom component taglib (or at least the attributes part) automatically.

I feel it's a little annoying having to declare the attributes in the component class and then again in the taglib file.

1

1 Answers

0
votes

I found a way to do that. I just have to use the properties of the FacesComponent annotation.

@FacesComponent(createTag = true, namespace = "http://myNamespace", tagName = "myComponent", value = "myComponent")

However the IDE (at least Netbeans) won't be able to autocomplete the component properties, which is a huge drawback. I wouldn't mind if there was a @ComponentAttribute annotation or something like that.

I ended up choosing to keep using the taglib file.