I want to dynamically create object of HtmlDivElement in my jsf managed bean and add it to panel but it seems that Html开发者_开发知识库DivElement is interface. So, how can i do it?
This is a pretty major confusion. The org.w3c.dom.html.HTMLDivElement
is not a JSF component. This represents a W3 DOM element which has an entirely different purpose (JAXP, DOM parsing).
You need a subclass of javax.faces.component.UIComponent
(just click your way through the "Direct Known Subclasses" in the aforelinked Javadoc to find them all). To render a HTML <div>
element, just use HtmlPanelGroup
whose layout
attribute is set to block
.
HtmlPanelGroup div = new HtmlPanelGroup();
div.setLayout("block");
someParentComponent.getChildren().add(div);
which does effectively the same as the following in "static" JSF:
<h:panelGroup layout="block" />
精彩评论