-
1. Re: [4.0.0-SNAPSHOT] Element interoperability
hr.stoyanov Apr 13, 2016 9:57 PM (in response to hr.stoyanov).. well, after looking at the example mention in the blog, i came up with some code that uses the new Element API and does the job:
Document document = getDocument();
final Body body = document.getBody();
//Add sidebar directly under body
body.appendChild(sidebarMenu.getElement());
//Add pusher directly under body next
final HTMLElement pusher = document.createElement("div");
pusher.setClassName("pusher");
body.appendChild(pusher);
//Add header menu under pusher
pusher.appendChild(headerMenu.getElement());
//Add content container under pusher
final HTMLElement contentContainer = document.createElement("div");
contentContainer.setId("contentContainer");
pusher.appendChild(contentContainer);
//Wire up navigation panel next
RootPanel.get(contentContainer.getId()).add(navigationPanel);
sidebarMenu.initialize();
headerMenu.initialize();
-
2. Re: [4.0.0-SNAPSHOT] Element interoperability
hr.stoyanov Apr 13, 2016 9:59 PM (in response to hr.stoyanov)... still, maybe some new methods can be added to Navigation to make this easier with the new Element API?
-
3. Re: [4.0.0-SNAPSHOT] Element interoperability
mbarkley Apr 14, 2016 11:12 AM (in response to hr.stoyanov)Hi Hristo,
As you've discovered it should be possible to build your entire UI with elements in Errai's hierarchy. That being said, it is actually quite easy to cast between different element wrappers. If you have cast-checking disabled, you can simply cast between them since they are both essentially compile-time wrappers for JavaScript element objects.
With cast-checking enabled, you can still transform between the two with JSNI methods. Here is code we use to do this in the framework: https://github.com/errai/errai/blob/master/errai-ui/src/main/java/org/jboss/errai/ui/shared/TemplateUtil.java#L158-L160
Cheers.
-
4. Re: [4.0.0-SNAPSHOT] Element interoperability
hr.stoyanov Apr 14, 2016 5:07 PM (in response to mbarkley)Thanks Max,
Maybe DOMUtils is a better home for such methods?
-
5. Re: [4.0.0-SNAPSHOT] Element interoperability
hr.stoyanov Apr 14, 2016 5:21 PM (in response to mbarkley)Max,
One more question - org.jboss.errai.ui.nav.client.local.TransitionAnchor is rooted into the old GWT Anchor class-->...-> Widget->UIObject. Are there any plans to switch to the new Anchor element class? Not sure you can do it in a backward compatible fashion, but placing it into another package might do the trick?
I am also missing some of the UIObject methods for dynamically showing/hiding UI stuff, such as:
- HasVisibility inteface
- public static native boolean isVisible(Element elem)
- public static native void setVisible(Element elem, boolean visible)
I started coding stuff like this one below, but it'd be nice if Errai 4's new Element API implemented similar helpers instead (in either DOMUtils or HTMLKElement?):
static public void setVisible(HTMLElement element, boolean visible) {
element.getStyle().setProperty("visibility", visible ? "visible" : "hidden");
}
Similar logic goes for the DISPLAY property...
Let me know if they already exist and I missed them ...
-
6. Re: [4.0.0-SNAPSHOT] Element interoperability
mbarkley Apr 15, 2016 10:39 AM (in response to hr.stoyanov)Are there any plans to switch to the new Anchor element class?
Yeah we will definitely have a replacement for that before 4 goes final.
As for the convenience methods, they're not high priority at the moment. But if you've written some convenience methods that you'd like to be in DOMUtils, please consider sending a pull request.
-
7. Re: [4.0.0-SNAPSHOT] Element interoperability
hr.stoyanov Apr 15, 2016 12:34 PM (in response to mbarkley)Thanks,
I will try to come up with a pull request for the helpers.