I would like to do absolute layout using said panel by only using ui.xml file however it isn't clear if this is possible since the documentation concentrates on the code and ignores the layout language altogether. I'm assuming, since the tutorial doesn't mention this, it is impossible but would like to know for sure.
I know this is old, but they updated the uibinder for AbsolutePanel
Use in UiBinder Templates
AbsolutePanel elements in UiBinder templates lay out their children with absolute position, using elements. Each at element should have left and top attributes in pixels. They also can contain widget children directly, with no position specified.
For example:
<g:AbsolutePanel>
<g:at left='10' top='20'>
<g:Label>Lorem ipsum...</g:Label>
</g:at>
<g:Label>...dolores est.</g:Label>
</g:AbsolutePanel>
You are right - there's no way to do this at the moment. This could be addressed in a future GWT release by introducing some custom syntax, like it was done for DockLayoutPanel
. But I doubt it - you'd want to write code like this:
<g:AbsolutePanel ui:field="absolutePanel">
<g:Button x="50px" y="50px">Test</g:Button>
</g:AbsolutePanel>
However this conflicts with the "bean" (as in Java Beans; if you have a getSomethingCool
method, you can write somethingCool="kewl"
in the UiBinder code and it will autmagically call the appropriate get/set method) style - because Button
doesn't have a setX/Y
method. This could be bypassed by replacing the setX/Y
calls with appropriate calls to existing methods (CSS positioning, etc) at compile time. But this introduces yet another custom behavior, dependent on the wrapping Widget/Panel - I think the GWT devs would like to avoid that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With