wffweb is one of the modules of webfirmframework. It's an open source java framework for realtime application development which can generate html5 and css3 from java code, read more...
Here are some sample codes
Html html = new Html(null) {
Head head = new Head(this);
Body body = new Body(this) {
Blank blank = new Blank(this, "Hello World");
};
};
// prepends the doc type <!DOCTYPE html>
html.setPrependDocType(true);
System.out.println(html.toHtmlString());
or the same in another coding style
Html html = new Html(null) {
{
new Head(this);
new Body(this) {
{
new NoTag(this, "Hello World");
}
};
}
};
// prepends the doc type <!DOCTYPE html>
html.setPrependDocType(true);
System.out.println(html.toHtmlString());
prints the following output
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Hello World
</body>
</html>
Div div = new Div(null);
or
Div div = new Div(null) {
};
prints :-
<div></div>
Div div = new Div(null) {
Div div1 = new Div(this);
Div div2 = new Div(this);
};
prints :-
<div>
<div>
</div>
<div>
</div>
</div>
Div div = new Div(null, new Width(50, CssLengthUnit.PX));
prints :-
<div width="50px"></div>
Div div = new Div(null, new Style(new BackgroundColor("green")));
prints :-
<div style="background-color: green;"></div>
final Style paragraphStyle = new Style("color:red");
Html html = new Html(null, new CustomAttribute("some", "val"), new Id("htmlId"),
new Style("background:white;width:15px")) {{
new Div(this, new Id("outerDivId")) {
int paragraphCount = 0;
Div contentDiv = new Div(this) {
{
new H1(this) {
NoTag headerContent = new NoTag(this, "Web Firm Framework");
};
for (paragraphCount = 1; paragraphCount < 4; paragraphCount++) {
new P(this, paragraphStyle) {
Blank paragraphContent = new Blank(this,
"Web Firm Framework Paragraph " + paragraphCount);
};
}
}
};
};
new Div(this, new Hidden());
}};
paragraphStyle.addCssProperty(AlignContent.CENTER);
System.out.println(html.toHtmlString());
prints
<html some="val" id="htmlId" style="background:white;width:15px;">
<div id="outerDivId">
<div>
<h1>Web Firm Framework</h1>
<p style="color:red;align-content:center;">Web Firm Framework Paragraph 1</p>
<p style="color:red;align-content:center;">Web Firm Framework Paragraph 2</p>
<p style="color:red;align-content:center;">Web Firm Framework Paragraph 3</p>
</div>
</div>
<div hidden></div>
</html>
and we can add/change styles later, eg:-
paragraphStyle.addCssProperties(new WidthCss(100, CssLengthUnit.PER));
Color color = (Color) paragraphStyle
.getCssProperty(CssNameConstants.COLOR);
color.setCssValue(CssColorName.BROWN.getColorName());
System.out.println(html.toHtmlString());
It will add width 100% in aboutParagraph and will change color to brown, its generated html code will be as follows
<html some="val" id="htmlId" style="background:white;width:15px;">
<div id="outerDivId">
<div>
<h1>Web Firm Framework</h1>
<p style="color:brown;align-content:center;width:100.0%;">Web Firm Framework Paragraph 1</p>
<p style="color:brown;align-content:center;width:100.0%;">Web Firm Framework Paragraph 2</p>
<p style="color:brown;align-content:center;width:100.0%;">Web Firm Framework Paragraph 3</p>
</div>
</div>
<div hidden></div>
</html>
Refer Developers Guide to get started
You can request features or report bugs here
Feel free to write us @ [email protected] for any assistance.