Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use AbsolutePanel in a UiBinder XML file

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.

like image 632
nick Avatar asked May 12 '10 22:05

nick


2 Answers

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>
like image 63
Matthew Sowders Avatar answered Sep 29 '22 16:09

Matthew Sowders


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.

like image 22
Igor Klimer Avatar answered Sep 29 '22 16:09

Igor Klimer