Creating a Login Manager Application with GWT Designer
Before you can start with the tutorial, you must install a supported version of the following:
Eclipse, Java 1.5 or higher, GWT Designer (Full stand-alone version), and the GWT SDK or Google Plugin for Eclipse (includes GWT SDK)
Note: This tutorial was created in Windows XP using GWT Designer 2.3, GPE 2.3, Eclipse 3.7 & Java 1.6.
Basic steps:
- Set the GWT installation directory
- Create a GWT Java Project and the LoginManager module
- Create the Login Composite
- Create and apply CSS styles
- Add Event Handlers
- Add the Login composite to the LoginManager module
- Run Application in Hosted Mode
- Build and Deploy
1. Set the path to the GWT SDK installation directory.
If you installed the Google Plugin for Eclipse (GPE), this step is not needed (GWT Designer will just use the SDK included with the GPE). Do this only if you downloaded the stand-alone GWT SDK zip file. The path would be the directory you unzipped the GWT SDK to (the dir just above the /doc subdirectory).

2. Create a GWT Java Project and the LoginManager module.



A LoginManager GWT project is created and configured. The LoginManager file is opened and you should see Source and Design tabs at the bottom of the LoginManager view. If you don't see the tabs, right-click on the Java class and select Open With > WindowBuilder Editor.

To start designing your UI using GWT Designer, click the Design tab. Below is GWT Designer's Design view. Top left corner of the LoginManager is the Components view. Below the Components view is the Properties view. In the middle is the Palette and to the right is your UI.

3. Create the Login Composite.
First, we need to create a Composite for the Login application.


Composite created and opened in Source mode.

Switch to Design mode and Add a VerticalPanel to the Composite.

Add a Label widget to the VerticalPanel.


To easily structure the widgets, add a FlexTable panel.
Add the following widgets to the FlexTable and arrange it as follows:

4. Create and apply CSS styles
Let's create a CSS style for the Label widgets.

The CSS Style Editor opens.



When you're done, you should have something similar to this:


Following the same procedure, create a style for the checkbox and set the styleName property.
Open the Login class and this is how it looks like with some css styling. Make sure to Save your work.

5. Add Event Handlers
First, let's convert the text boxes from local to field variables.

Now, let's add an onClick event for the "Sign In" button.
As you can see a ClickHandler has been added and all you have to do is implement the onClick event.
import com.google.gwt.user.client.Window;
if (textBoxUsername.getText().length() == 0
|| textBoxPassword.getText().length() == 0) {
Window.alert("Username or password is empty.");
}
6. Add the Login Composite to the LoginManager module.



7. Run your Application in Hostedmode.

You should now see the LoginManager application similar to the screen below.


8. Build and Deploy.


this article very use full for me....Thanks ! sagar...
ReplyDelete