WFF

wffweb - Java framework to develop web applications

View sample projects on GitHub

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
<div attribute-with="value"></div>
Custom attribute without value :
Div div = new Div(null, new CustomAttribute("attribute-without-value"));
System.out.println(div);
prints
<div attribute-without-value></div>

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
<div common-data="data1">
    <div common-data="data2"></div>
</div>

Next >>



Subscribe on youtube for technical videos