Skip to content

Instantly share code, notes, and snippets.

@webfirmframework
Last active October 2, 2019 02:47
Show Gist options
  • Save webfirmframework/3d758303988006aecbf3ce7e9eb89bb5 to your computer and use it in GitHub Desktop.
Save webfirmframework/3d758303988006aecbf3ce7e9eb89bb5 to your computer and use it in GitHub Desktop.
Example for getRootTag method on a tag
import com.webfirmframework.wffweb.tag.html.Body;
import com.webfirmframework.wffweb.tag.html.Html;
import com.webfirmframework.wffweb.tag.html.TitleTag;
import com.webfirmframework.wffweb.tag.html.attribute.global.Id;
import com.webfirmframework.wffweb.tag.html.metainfo.Head;
import com.webfirmframework.wffweb.tag.html.stylesandsemantics.Div;
import com.webfirmframework.wffweb.tag.htmlwff.NoTag;
import com.webfirmframework.wffweb.tag.repository.TagRepository;
public class RootTagOnTagUsage {
public static void main(String[] args) {
// use latest version to use this coding style
Html rootTag = new Html(null).give(html -> {
new Head(html).give(head -> {
new TitleTag(head).give(title -> {
new NoTag(title, "some title");
});
});
new Body(html, new Id("one")).give(body -> {
new Div(body);
});
});
Div div = TagRepository.findOneTagAssignableToTag(Div.class, rootTag);
// prints true because the root tag of the whole hierarchy is rootTag
System.out.println(div.getRootTag().equals(rootTag));
}
}
@webfirmframework
Copy link
Author

webfirmframework commented Jan 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment