concept LoginDialogBox in category gwt

This is an excerpt from Manning's book GWT in Action.
In planning, we decided to turn the designer’s code into a subclass of PopupPanel, and we decided to name the widget LoginDialogBox. By default the UiBinder template, which is an XML file, needs to have the same name as the Java class that will use it, so we created a template file named LoginDialogBox.ui.xml.
Looking again at the <ui:style> block you added to the LoginDialogBox template, you see that you’ll need to access all four style classes in your Java widget code:
<ui:style field="myStyle"> .hidden { visibility: hidden; } .borderEmpty { border: 3px #999999 solid; } .borderOk { border: 3px green solid; } .borderError { border: 3px red solid; } </ui:style>The <ui:style> block contains four styles, so when UiBinder generates the Css-Resource, it will create four methods: hidden(), borderEmpty(), borderOk(), and borderError(). As we mentioned, you need to create an interface for this if you want to be able to access these methods within your code. And because this interface will only be used within your widget class, you’ll nest it inside your LoginDialogBox so that you can keep everything together:
You now have access to the CSS class name in your application. Building on our LoginDialogBox you can now add a host of handler methods to perform your client-side validation of the form, as shown next.
![]()
If you’ve been following along with the LoginDialogBox example, this code completes the project. It defines six handlers and three utility methods. Of the three utility methods, validateEmail and validatePassword do what you would expect, so we won’t discuss them here. The third, setBorderStyle()
, makes use of your newly added myStyle field. It takes a TextBox and style name as inputs, removing all border styles from the TextBox before adding the supplied style name.
, makes use of your newly added myStyle field. It takes a TextBox and style name as inputs, removing all border styles from the TextBox before adding the supplied style name.