Agile Ajax

Another Look at Thinwire

When it looked at Thinwire -- the server-side Ajax framework -- last, it was early days yet. Back then it was a little rough around the edges. They've come a long way in the intervening time. I even skimmed the new ThinWire Handbook from Prentice Hall and the IBM Developerworks tutorial on Thinwire. One thing still bugs me, though, namely that you have to specify position and size for all of your elements. Take a look at this embedded style from the DOM of a Thinwire app:

border: 0pt solid transparent; margin: 0px; padding: 0px; overflow: hidden; position: absolute; vertical-align: middle; white-space: nowrap; background-color: transparent; background-repeat: no-repeat; background-position: left top; font-family: Tahoma,sans-serif; color: windowtext; font-size: 8pt; font-style: normal; font-weight: normal; text-decoration: none; text-align: left; height: 0px; line-height: 0px; left: 0px; top: 0px; width: 0px; display: block;

The above is the embedded style for a Label element. Absolute positioning. OK. That's doable. But in order to get something other than 0px height and weight, you have to specify component boundaries. Do I have to calculate height and width for every text string and font type, style and size? Yes, and the framework provides methods for that. Yeesh. Certainly all of the source code I've read seems to be festooned with hardcoded dimensions. That sets my teeth on edge and reminds be of the bad old days of GridBagLayout (without any of the good parts).

The TableLayout is scary, what with having to pass in comma separated numbers in a text string (!) to specify the cell dimensions of a component.

p.getChildren().add(label.setLimit("0, 0, 1, 1"));

This points out one thing that seems to be missing in Thinwire and, in my opinion, needs to be addressed. If you're not going to use the layout of the browser, you have to provide some sort of automatic layout of your own. TableLayout doesn't look to be that solution.

Maybe I've just missed the whole point of this framework, but I can think of better ways to spend my time than counting pixels and writing layout logic. That's really something that I expect the framework to provide.

Technorati Tags: , ,

Topics:

Comments: 1 so far

  1. Dietrich,

    While I can see what you are saying about having to specify the width/height of a label, its not true if you use TableLayout ina different way. For instance, if you are using a Label to display free flowing text that you want to wrap properly and behave more like a traditional web page, you can set the ‘wrapText’ property on Label to get it to wrap as the size of the label changes (you can also embed some html). Then you just place the Label into a TableLayout cell that has a column set to a relative width/height:

    —–
    Frame f = Application.current().getFrame();
    //Setup two columns, one at 50% and then one remainder.
    //Also add one row that takes up the whole height of the container
    f.setLayout(new TableLayout(new double[][]{{.5,0},{0}}));

    Label l = new Label(getReallyLongText());
    l.setWrapText(true);

    //Add label to frame, placing it in column 0, row 0.
    //NOTE: No width/height specified.
    f.getChildren().add(l.setLimit(”0,0″));
    ——

    If you need more HTMLish capability for static text areas, you can replace the Label with a WebBrowser component and set the border size of the WebBrowser to 0, so it behaves mostly like a Label. Then just call setContent to set the content:

    ——
    WebBrowser l = new WebBrowser();
    l.getStyle().getBorder().setSize(0);
    l.setContent(”…complex html… “);
    ——

    In one way or another, you have to address layout in any application you create, ThinWire just approaches things differently. For lots of well formated read-only content, its a little tricky, so just use a WebBrowser component for those parts. However, for data entry forms and business UI’s, I think this approach works pretty well and gives you exact control over how the user interface is presented. This is not to say that we won’t do something more automatic in the future that is built on top of this, but we’ve been mainly focused on getting the foundation solid and working perfectly. Keep an eye on us! ;)

    Comment by Joshua Gertzen, Thursday, August 9, 2007 @ 1:02 pm

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com