WFF

wffweb - Java framework to develop web applications

View sample projects on GitHub
Use latest version of wffweb to get better stability, performance and thread-safety.

com.webfirmframework.wffweb.tag.htmlwff.CustomTag class can be used to create a new tag similar to the existing tags like Div .

public class NewTag extends CustomTag {

    private static final long serialVersionUID = 1L;

    public NewTag(AbstractHtml base, AbstractAttribute... attributes) {
        super("newtag", TagType.OPENING_CLOSING, base, attributes);
    }

    // TODO your own feature methods

    @Override
    public NewTag clone() throws CloneNotSupportedException {
        return (NewTag) super.clone();
    }

}

NewTag may be used as a tag like Div tag. The below code shows custom tag without keeping a separate class

CustomTag customTag = new CustomTag("newtag", null, new Id("ct1Id")) {
    CustomTag customTag = new CustomTag("anothertag", this);
};
System.out.println(customTag.toHtmlString());
this code will print
<newtag id="ct1Id">
    <anothertag></anothertag>
</newtag>

The first argument in CustomTag constructor is tag name. There are three types of TagType , TagType.OPENING_CLOSING , TagType.SELF_CLOSING and TagType.NON_CLOSING . Example for TagType.OPENING_CLOSING is

<div></div> which has opening and closing tag. Example for TagType.SELF_CLOSING is <input type="text"/> which can be self closed and no need to have a closing tag. Example for TagType.NON_CLOSING is <meta charset="UTF-8"> which need neither be self closed nor be closed with closing tag.

Next >>



Subscribe on youtube for technical videos