Hi,
In errai refernce documentation : org.jboss.errai.common.client.dom.Document
is a thin wrapper around the DOM document provided by Errai . his line assumes that TemplatedBean
implements org.jboss.errai.ui.client.local.api.elemental2.IsElement
. The default implementation of IsElement.getElement
returns the root element of the component as an Errai DOM wrapper, which is compatible with the injected Document
.
I have this code which is using isElement from elemntal2
@Page(role = DefaultPage.class) @Templated @ApplicationScoped public class WelcomePage implements
{ @Inject @DataField HTMLDivElement div; @Override public HTMLElement getElement() { return div; } }
and this code
@Inject org.jboss.errai.common.client.dom.Document doc; @PostConstruct public void init() { doc.getBody().appendChild(page.getElement()); // Document.get().getBody().appendChild(page.getElement()); }
and I get compile exception : in the type Node is not applicable for the arguments (HTMLElement)
mbarkley can you help me ? am I doing sth wrong ?
PS : errai version is 4.1.0.Final
Hi Omid,
You'll need to use the elemental2 HTMLDocument. By default it is not injectable. I have updated the errai-tutorial to demonstrate how you can easily make fields from elemental2 DomGlobal (where the document object is) injectable.
Cheers.