Java Reference
In-Depth Information
private class instance variables, which will allow you to track the row and column
with which the user is currently interacting.
// tracks the current row and column in the grid
private int currentRow = 0;
private int currentColumn = 0;
Add a new event handler to the FlexTable and an anonymous inner class to
implement ClickEvent . In this listener you want to determine the column and row for
which the user is entering time. You'll use these values to total each row and validate
user input.
flexEntryTable.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
HTMLTable.Cell cellForEvent =
flexEntryTable.getCellForEvent(event);
currentRow = cellForEvent.getRowIndex();
currentColumn = cellForEvent.getCellIndex();
}
});
Virtually every application requires validating user input to ensure valid
parameters and data integrity. Your application is no different, however GWT is very
weak in the validation department. A few frameworks can address this situation, but
they are outside the scope of this topic. You'll implement some simple validation
using some standard and GWT components.
You need to ensure that the time that users enter are valid numbers and that they
do not enter more than 24 hours for a single day. Instead of writing a series of
listeners for each text box , you'll write a single handler and listener that will be
shared by all data-entry text boxes .
private ValueChangeHandler<String> timeChangeHandler = new
ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> evt) {
try {
double t = Double.parseDouble(evt.getValue());
if (t > 24) {
Window.alert("You cannot work more than 24 hours
a day.");
} else {
totalRow();
111
 
Search WWH ::




Custom Search