http://download.instantiations.com/D2WB ... nager.html
When I get the part where the onClick is modified to test the textBoxUsername and Password fields, as given in the tutorial, I am getting a java error:
Cannot refer to a non-final variable textBoxUsername inside an inner class defined in a different method. I get a similar error on the textBoxPassword field as well
Here is my full code:
====================================
- Code: Select all
package com.gwt.tutorial.LoginManager.client;
import com.google.gwt.user.client.ui.Composite;
public class Login extends Composite {
private Label lblUsername;
private Label lblPassword;
public Login() {
VerticalPanel verticalPanel = new VerticalPanel();
initWidget(verticalPanel);
Label lbSignInTo = new Label("Sign In");
verticalPanel.add(lbSignInTo);
FlexTable flexTable = new FlexTable();
verticalPanel.add(flexTable);
lblUsername = new Label("Username:");
flexTable.setWidget(0, 0, lblUsername);
TextBox textBoxUsername = new TextBox();
flexTable.setWidget(0, 1, textBoxUsername);
lblPassword = new Label("Password:");
flexTable.setWidget(1, 0, lblPassword);
TextBox textBoxPassword = new TextBox();
flexTable.setWidget(1, 1, textBoxPassword);
CheckBox chckbxRememberMeOn = new CheckBox("Remember me on this computer.");
flexTable.setWidget(2, 1, chckbxRememberMeOn);
Button btnSigninbutton = new Button("SigninButton");
btnSigninbutton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
if (textBoxUsername.getText().length() == 0
|| textBoxPassword.getText().length() == 0) {
Window.alert("Username or password is empty.");
}
}
});
btnSigninbutton.setText("Sign in");
flexTable.setWidget(3, 1, btnSigninbutton);
}
}
===================================================
Where have I screwed up?
--EB