table.setText(0, 2, "Price");
table.setText(0, 3, "My bid");
for (int i = 0; i < itens.size(); i++) {
final AuctionItem item = (AuctionItem) itens.get(i);
final int itemId = item.getId();
final Label labelNumberOfBids = new Label(String.valueOf(item.getNumberOfBids()));
final Label labelPrice = new Label("$ " + String.valueOf(item.getPrice()));
final TextBox txtBoxMyBid = new TextBox();
final Button bidButton = new Button("Bid!");
final Label labelMessage = new Label("");
bidButton.setStylePrimaryName("principal");
//Save itemPrice Label to be used when new bids are processed.
mapOfItemPrices.put(new Integer(itemId), labelPrice);
//Save numberOfBids Label to be used when new bids are processed.
mapOfNumberOfBids.put(new Integer(itemId), labelNumberOfBids);
//Handle ENTER key
txtBoxMyBid.addKeyboardListener(new KeyboardListener() {
public void onKeyUp(Widget sender, char keyCode, int modifiers) {
if (keyCode == '\r') {
sendNewBid(item, txtBoxMyBid, labelMessage);
}
}
public void onKeyDown(Widget sender, char keyCode, int modifiers) {
}
public void onKeyPress(Widget sender, char keyCode, int modifiers) {
}
});
//Handle button click
bidButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
sendNewBid(item, txtBoxMyBid, labelMessage);
}
});
table.setText(i + 1, 0, item.getName());
table.setWidget(i + 1, 1, labelNumberOfBids);
table.setWidget(i + 1, 2, labelPrice);
table.setWidget(i + 1, 3, txtBoxMyBid);
table.setWidget(i + 1, 4, bidButton);
table.setWidget(i + 1, 5, labelMessage);