I'm trying to get control when a user browses a file name into the FileItem field. I have tried adding ChangedHandler, ChangeHandler, and ClickHandler.
None of these handlers get control when the user browses a file name. Here is the code:
In the code above none of the handlers get control when a file name is browsed into the file name text box of the FileItem.
None of these handlers get control when the user browses a file name. Here is the code:
Code:
final FileItem upload = new FileItem(Schema.DSF_UPLOADEDFILE);
upload.setShowTitle(false);
upload.setEndRow(false);
upload.setWidth(Dimensions.STANDARD_CELL_WIDTH * 2);
final String FILE_NAME_VALIDATION = ".*\\.xlsx";
RegExpValidator regExpValidator = new RegExpValidator();
regExpValidator.setExpression(FILE_NAME_VALIDATION);
regExpValidator.setErrorMessage("must be a Microsoft Excel file ending with .xlsx");
upload.setValidators(regExpValidator);
upload.setValidateOnChange(true);
upload.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
Object getValue = upload.getValue();
ClientLogger.log(this, "getValue=", getValue);
}
});
upload.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
Object getValue = upload.getValue();
ClientLogger.log(this, "getValue=", getValue);
}
});
upload.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Object getValue = upload.getValue();
ClientLogger.log(this, "getValue=", getValue);
}
});
Comment