-
Notifications
You must be signed in to change notification settings - Fork 3
6. How to create a custom tag
Web Firm Framework edited this page Aug 19, 2017
·
3 revisions
You can use CustomTag class to create a custom tag. See the below sample
CustomTag customTag = new CustomTag("newtag", null, new Id("ct1Id")) {
CustomTag customTag = new CustomTag("anothertag", this);
};
System.out.println(customTag.toHtmlString(true));
which prints
<newtag id="ct1Id">
<anothertag></anothertag>
</newtag>
OR you can keep your own class for a new tag by extending CustomTag class, eg:-
import com.webfirmframework.wffweb.tag.html.AbstractHtml;
import com.webfirmframework.wffweb.tag.html.attribute.core.AbstractAttribute;
import com.webfirmframework.wffweb.tag.htmlwff.CustomTag;
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();
}
}
and you can use it as
public static void main(String[] args) {
NewTag newTag = new NewTag(null, new Id("1")) {
NewTag newTag = new NewTag(this, new Id("2"));
};
System.out.println(newTag.toHtmlString(true));
}
this will print
<newtag id="1">
<newtag id="2"></newtag>
</newtag>
Refer wffweb-javadoc, Watch technical videos
Feel free to write us @ [email protected] for any assistance
or
[email protected] for any technical support.
webfirmframework.com since 2014