I've been having a problem using the Listbox with the UIbinder but I can't
seem to figure out why the following code doesn't populate the listbox on
startup?
public class RegistrationViewImpl extends Composite implements
RegistrationView {
private static RegistrationViewUiBinder uiBinder =
GWT.create(RegistrationViewUiBinder.class);
@UiField Button register;
@UiField Button postcodeLookup;
@UiField TextBox tbxFirstName;
@UiField TextBox tbxSurname;
@UiField TextBox tbxEmail;
@UiField(provided=true) ListBox lbxDay;
@UiField(provided=true) ListBox lbxMonth;
@UiField(provided=true) ListBox lbxYear;
@UiField(provided=true) ListBox lbxGender;
@UiField(provided=true) ListBox lbxInterestedIn;
@UiField TextBox tbxPostcode;
@UiField ListBox lbxAddress;
@UiField TextBox tbxUsername;
@UiField PasswordTextBox tbxPassword;
@UiField PasswordTextBox tbxCfmPassword;
private Presenter presenter;
@UiTemplate("RegistrationViewImpl.ui.xml")
interface RegistrationViewUiBinder extends UiBinder<Widget,
RegistrationView> {
}
public RegistrationViewImpl() {
lbxDay = new ListBox(false);
lbxMonth = new ListBox(false);
lbxYear = new ListBox(false);
lbxGender = new ListBox(false);
lbxInterestedIn = new ListBox(false);
populateListBoxes();
initWidget(uiBinder.createAndBindUi(this));
}
private void populateListBoxes() {
for (Integer day = 1; day <= 31; day++ ){
lbxDay.addItem(day.toString());
}
lbxDay.setVisibleItemCount(1);
lbxMonth.addItem("January");
lbxMonth.addItem("February");
lbxMonth.addItem("March");
lbxMonth.addItem("April");
lbxMonth.addItem("May");
lbxMonth.addItem("June");
lbxMonth.addItem("July");
lbxMonth.addItem("August");
lbxMonth.addItem("September");
lbxMonth.addItem("October");
lbxMonth.addItem("November");
lbxMonth.addItem("December");
lbxMonth.setVisibleItemCount(1);
int currentYear = DateUtil.getYearAsInt(new Date());
for (Integer year = 1900; year<=currentYear; year++){
lbxYear.addItem(year.toString());
}
lbxYear.setVisibleItemCount(1);
lbxGender.addItem(Gender.Man.toString());
lbxGender.addItem(Gender.Woman.toString());
lbxInterestedIn.addItem(Gender.Man.toString());
lbxInterestedIn.addItem(Gender.Woman.toString());
}
@UiHandler("register")
void onRegisterClick(ClickEvent event) {
if (!tbxPassword.getText().equals(tbxCfmPassword.getText())) {
Window.alert("Passwords do not match.");
}
User user = new User(tbxUsername.getText(),tbxEmail.getText());
user.firstName = tbxFirstName.getText();
user.lastName = tbxSurname.getText();
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy.MM.dd");
String day = lbxDay.getItemText(lbxDay.getSelectedIndex());
String month = lbxMonth.getItemText(lbxMonth.getSelectedIndex());
String year = lbxYear.getItemText(lbxYear.getSelectedIndex());
user.dob = fmt.parse(year + "" + month + "." + day);
user.gender =
Gender.valueOf(lbxGender.getItemText(lbxGender.getSelectedIndex()));
user.interestedIn =
Gender.valueOf(lbxInterestedIn.getItemText(lbxInterestedIn.getSelectedIndex()));
user.address.postcode = tbxPostcode.getText();
user.address.houseNumber =
lbxAddress.getItemText(lbxAddress.getSelectedIndex());
presenter.onRegisterUser(user, tbxPassword.getText());
}
@UiHandler("postcodeLookup")
void onPostcodeLookupClick(ClickEvent event) {
}
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}
}
and the XML..
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:p1="urn:import:com.google.gwt.user.datepicker.client">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<g:LayoutPanel width="527px" height="515px">
<g:layer left="144px" width="73px" top="11px" height="18px">
<g:Label text="First Name:"/>
</g:layer>
<g:layer left="223px" width="186px" top="4px" height="25px">
<g:TextBox name="tbxFirstName" ui:field="tbxFirstName"/>
</g:layer>
<g:layer left="157px" width="60px" top="42px" height="18px">
<g:Label text="Surname:"/>
</g:layer>
<g:layer left="223px" width="186px" top="35px" height="25px">
<g:TextBox name="tbxSurname" ui:field="tbxSurname"/>
</g:layer>
<g:layer left="171px" width="46px" top="73px" height="18px">
<g:Label text="Email:"/>
</g:layer>
<g:layer left="223px" width="186px" top="66px" height="25px">
<g:TextBox name="tbxEmail" ui:field="tbxEmail"/>
</g:layer>
<g:layer left="132px" width="85px" top="101px" height="18px">
<g:Label text="Date Of Birth:"/>
</g:layer>
<g:layer left="223px" width="70px" top="97px" height="43px">
<g:ListBox ui:field="lbxDay" height=""/>
</g:layer>
<g:layer left="299px" width="118px" top="97px" height="22px">
<g:ListBox name="lbxMonth" ui:field="lbxMonth"/>
</g:layer>
<g:layer left="419px" width="70px" top="97px" height="22px">
<g:ListBox name="lbxYear" ui:field="lbxYear"/>
</g:layer>
<g:layer left="165px" width="52px" top="142px" height="18px">
<g:Label text="Gender:"/>
</g:layer>
<g:layer left="223px" width="105px" top="138px" height="22px">
<g:ListBox name="lbxGender" ui:field="lbxGender"/>
</g:layer>
<g:layer left="132px" width="85px" top="170px" height="18px">
<g:Label text="Interested in:"/>
</g:layer>
<g:layer left="222px" width="187px" top="166px" height="22px">
<g:ListBox name="lbxInterestedIn"
ui:field="lbxInterestedIn" />
</g:layer>
<g:layer left="161px" width="60px" top="233px" height="18px">
<g:Label text="Postcode:"/>
</g:layer>
<g:layer left="227px" width="186px" top="226px" height="25px">
<g:TextBox name="tbxPostcode" ui:field="tbxPostcode"/>
</g:layer>
<g:layer left="161px" width="60px" top="261px" height="18px">
<g:Label text="Address:"/>
</g:layer>
<g:layer left="227px" width="186px" top="257px" height="22px">
<g:ListBox name="lbxAddress" ui:field="lbxAddress"/>
</g:layer>
<g:layer left="147px" width="70px" top="329px" height="18px">
<g:Label text="Username:"/>
</g:layer>
<g:layer left="223px" width="186px" top="322px" height="25px">
<g:TextBox name="tbxUsername" ui:field="tbxUsername"/>
</g:layer>
<g:layer left="157px" width="60px" top="360px" height="18px">
<g:Label text="Password:"/>
</g:layer>
<g:layer left="223px" width="186px" top="353px" height="25px">
<g:PasswordTextBox name="tbxPassword"
ui:field="tbxPassword"/>
</g:layer>
<g:layer left="99px" width="118px" top="391px" height="18px">
<g:Label text="Confirm Password:"/>
</g:layer>
<g:layer left="223px" width="186px" top="384px" height="25px">
<g:PasswordTextBox name="tbxCfmPassword"
ui:field="tbxCfmPassword"/>
</g:layer>
<g:layer left="419px" width="70px" top="226px" height="24px">
<g:Button text="Lookup" ui:field="postcodeLookup"/>
</g:layer>
<g:layer left="378px" width="85px" top="456px" height="24px">
<g:Button ui:field="register">Register</g:Button>
</g:layer>
</g:LayoutPanel>
</g:HTMLPanel>
</ui:UiBinder>
I'm pretty sure that this is something simple and noddy, can anyone point
me in the right direction?
Cheers
hegsie
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/WVc55U6-snMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.