I received a number of emails regarding my last post, GWT UiBinder Hello World Tutorial, specifically how to pass values into widgets using the new GWT 2.0 UiBinder. Here's a small tutorial on one of the ways in which you could do that. I plan on another tutorial on passing multiple objects using the @UiFactory method.
So here is the Entry Point class. When the module loads, it creates a new MyPanel object, passes the text "Random Text" to the constructor and then adds the panel to the RootPanel.
</p><p style="clear: both">The MyPanel owner class defines a new constructor that accepts the passed string value (i.e. “Random Text”) and sets the value of hidden field called myField in the UiBinder template to this text.</p>
When the UiBinder template runs, its owner class loads the value ("Random Text") into the Hidden field which then passes this same value into the SomeWidget widget.
The SomeWidget owner class is fairly straight forward. There is a setter method for MyField which runs after the constructor, receives the text ("Random Text") and writes it to the displayText field in the UiBinder template.
The UiBinder template simply displays the text in an HTMLPanel.