As explained in attributes
section, custom attribute may also be considered as two,
com.webfirmframework.wffweb.tag.html.attributewff.CustomAttribute
class can be used to create a new attribute similar to the existing attribures
like
Id
and
com.webfirmframework.wffweb.tag.html.attribute.event.CustomEventAttribute
which can be used to create a new event attribute similar to existing event attributes like OnClick.
CustomAttribute
Custom attribute with value :
Div div = new Div(null, new CustomAttribute("attribute-with", "value"));
System.out.println(div);
prints
Custom attribute without value :
Div div = new Div(null, new CustomAttribute("attribute-without-value"));
System.out.println(div);
prints
You can also keep your own implementation class by extending CustomAttribute class, see the below samples
To create custom attribute as a separate class
import com.webfirmframework.wffweb.tag.html.attributewff.CustomAttribute;
public class CommonDataAttribute extends CustomAttribute {
private static final long serialVersionUID = 1L;
public CommonDataAttribute(String attributeValue) {
super("common-data", attributeValue);
}
// TODO write the feature methods for this attribute
}
public static void main(String[] args) {
Div div = new Div(null, new CommonDataAttribute("data1")) {
Div div = new Div(this, new CommonDataAttribute("data2"));
};
System.out.println(div.toHtmlString());
}
this will print
Subscribe on youtube for technical videos