本文整理汇总了Java中com.vaadin.data.Validator.InvalidValueException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidValueException类的具体用法?Java InvalidValueException怎么用?Java InvalidValueException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidValueException类属于com.vaadin.data.Validator包,在下文中一共展示了InvalidValueException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
@Override
public void commit() throws SourceException, InvalidValueException {
final CommitHandler<ITEM> handler = getCommitHandler()
.orElseThrow(() -> new IllegalStateException("Missing CommitHandler"));
List<ITEM> added = requireItemStore().getAddedItems().stream().map(i -> requireItemAdapter().restore(this, i))
.collect(Collectors.toList());
List<ITEM> modified = requireItemStore().getModifiedItems().stream()
.map(i -> requireItemAdapter().restore(this, i)).collect(Collectors.toList());
List<ITEM> removed = requireItemStore().getRemovedItems().stream()
.map(i -> requireItemAdapter().restore(this, i)).collect(Collectors.toList());
if (!added.isEmpty() || !modified.isEmpty() || !removed.isEmpty()) {
final List<ITEM> addedItemReversed = new ArrayList<>(added);
Collections.reverse(addedItemReversed);
handler.commit(addedItemReversed, modified, removed);
// reset items store
requireItemStore().reset(false, false);
}
}
示例2: RequiredIntegerField
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
/**
* Constructeur
*/
public RequiredIntegerField() {
super();
setConverter(new StringToIntegerConverter() {
private static final long serialVersionUID = -1725520453911073564L;
@Override
protected NumberFormat getFormat(Locale locale) {
return new DecimalFormat("#");
}
});
addValidator(value->{
if (value==null){
return;
}
Integer integerValue = null;
try{
integerValue = Integer.valueOf(value.toString());
}catch (Exception e){
throw new InvalidValueException(getConversionError());
}
if (value!=null && integerValue<0){
throw new InvalidValueException(getConversionError());
}
});
}
示例3: doSave
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void doSave() {
try {
//
// Commit changes
//
self.tableFunctions.commit();
//
// We are saved
//
self.isSaved = true;
//
// Close the window
//
self.close();
} catch (SourceException | InvalidValueException e) {
return;
}
}
示例4: doSave
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void doSave() {
try {
//
// Commit changes
//
self.tableFunctions.commit();
//
// We are saved
//
self.isSaved = true;
//
// Close the window
//
self.close();
} catch (SourceException | InvalidValueException e) { //NOPMD
//
// Nothing to do, Vaadin highlights
//
}
}
示例5: initializeButton
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void initializeButton() {
self.buttonSave.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
try {
//
// Commit
//
self.textFieldColumn.commit();
//
// If we get here, the value is valid.
// Mark ourselves as saved and close the window
//
self.isSaved = true;
self.close();
} catch (SourceException | InvalidValueException e) { //NOPMD
//
// Vaadin will display error
//
}
}
});
}
示例6: validate
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
@Override
public void validate() throws InvalidValueException {
if (this.mainLayout.getComponentCount() == 0) {
return;
}
Component c = this.mainLayout.getComponent(0);
if (c instanceof SQLPIPConfigurationComponent) {
((SQLPIPConfigurationComponent)c).validate();
} else if (c instanceof LDAPPIPConfigurationComponent) {
((LDAPPIPConfigurationComponent)c).validate();
} else if (c instanceof CSVPIPConfigurationComponent) {
((CSVPIPConfigurationComponent)c).validate();
} else if (c instanceof HyperCSVPIPConfigurationComponent) {
((HyperCSVPIPConfigurationComponent)c).validate();
} else if (c instanceof CustomPIPConfigurationComponent) {
((CustomPIPConfigurationComponent)c).validate();
}
super.validate();
}
示例7: commit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
@Override
public void commit() throws SourceException, InvalidValueException {
if (this.mainLayout.getComponentCount() == 0) {
return;
}
Component c = this.mainLayout.getComponent(0);
if (c instanceof SQLPIPConfigurationComponent) {
((SQLPIPConfigurationComponent)c).commit();
} else if (c instanceof LDAPPIPConfigurationComponent) {
((LDAPPIPConfigurationComponent)c).commit();
} else if (c instanceof CSVPIPConfigurationComponent) {
((CSVPIPConfigurationComponent)c).commit();
} else if (c instanceof HyperCSVPIPConfigurationComponent) {
((HyperCSVPIPConfigurationComponent)c).commit();
} else if (c instanceof CustomPIPConfigurationComponent) {
((CustomPIPConfigurationComponent)c).commit();
}
super.commit();
}
示例8: getFormPropertyValues
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
/**
* Returns all values filled in in the writable fields on the form.
*
* @throws InvalidValueException when a validation error occurs.
*/
public Map<String, String> getFormPropertyValues() throws InvalidValueException {
// Commit the form to ensure validation is executed
form.commit();
Map<String, String> formPropertyValues = new HashMap<String, String>();
// Get values from fields defined for each form property
for(FormProperty formProperty : formProperties) {
if(formProperty.isWritable()) {
Field field = form.getField(formProperty.getId());
FormPropertyRenderer renderer = getRenderer(formProperty);
String fieldValue = renderer.getFieldValue(formProperty, field);
formPropertyValues.put(formProperty.getId(), fieldValue);
}
}
return formPropertyValues;
}
示例9: getAttachment
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
public Attachment getAttachment() throws InvalidValueException {
// Force validation of the fields
form.commit();
// Check if file is uploaded
if(!fileUploaded) {
InvalidValueException ive = new InvalidValueException(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_REQUIRED));
form.setComponentError(ive);
throw ive;
}
if(attachment != null) {
applyValuesToAttachment();
} else {
// Create new attachment based on values
// TODO: use explorerApp to get services
attachment = taskService.createAttachment(mimeType, taskId, processInstanceId,
getAttachmentName(), getAttachmentDescription(), new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
}
return attachment;
}
示例10: handleFormSubmit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void handleFormSubmit() {
try {
// create user
form.commit(); // will throw exception in case validation is false
User user = createUser();
// close popup and navigate to fresh user
close();
ExplorerApp.get().getViewManager().showUserPage(user.getId());
// Update user cache
ExplorerApp.get().getUserCache().notifyUserDataChanged(user.getId());
} catch (InvalidValueException e) {
// Do nothing: the Form component will render the errormsgs automatically
setHeight(340, UNITS_PIXELS);
}
}
示例11: handleFormSubmit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void handleFormSubmit() {
try {
// Check for errors
form.commit(); // will throw exception in case validation is false
// Create task
Task task = taskService.newTask();
task.setName(nameField.getValue().toString());
task.setDescription(descriptionArea.getValue().toString());
task.setDueDate((Date) dueDateField.getValue());
task.setPriority(priorityComboBox.getPriority());
task.setOwner(ExplorerApp.get().getLoggedInUser().getId());
taskService.saveTask(task);
// close popup and navigate to new group
close();
ExplorerApp.get().getViewManager().showTasksPage(task.getId());
} catch (InvalidValueException e) {
// Do nothing: the Form component will render the errormsgs automatically
setHeight(350, UNITS_PIXELS);
}
}
示例12: createQueryValidator
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
private Validator createQueryValidator() {
Validator validator = new Validator() {
private static final long serialVersionUID = -186376062628005948L;
@Override
public void validate(Object value) throws InvalidValueException {
String query = ((String) value).trim();
if (!query.toLowerCase().startsWith("select")) {
throw new InvalidValueException(ctx.tr("dialog.errors.validation.select"));
}
}
};
return validator;
}
示例13: commit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
@Override
public void commit() throws SourceException, InvalidValueException {
Integer roleId = (Integer) roleComboBox.getValue();
if (roleId == -1) {
if (CurrentProjectVariables.isAdmin()) {
beanItem.setIsadmin(Boolean.TRUE);
this.setInternalValue(null);
} else {
throw new UserInvalidInputException(UserUIContext.getMessage(ProjectRoleI18nEnum.ERROR_ONLY_OWNER_ASSIGN_ROLE_OWNER));
}
} else {
beanItem.setIsadmin(Boolean.FALSE);
this.setInternalValue((Integer) this.roleComboBox.getValue());
}
super.commit();
}
示例14: commit
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
@Override
public void commit() throws SourceException, InvalidValueException {
Integer roleId = (Integer) roleBox.getValue();
if (roleId == -1) {
if (!UserUIContext.isAdmin()) {
throw new UserInvalidInputException(UserUIContext.getMessage(RoleI18nEnum.ERROR_ONLY_OWNER_CAN_ASSIGN_OWNER_ROLE));
} else {
user.setAccountOwner(Boolean.TRUE);
user.setRoleName(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
}
} else {
user.setAccountOwner(Boolean.FALSE);
BeanItem<SimpleRole> role = (BeanItem<SimpleRole>) roleBox.getItem(roleId);
if (role != null) {
user.setRoleName(role.getBean().getRolename());
}
}
setInternalValue(roleId);
super.commit();
}
示例15: initializeButton
import com.vaadin.data.Validator.InvalidValueException; //导入依赖的package包/类
protected void initializeButton() {
this.buttonSave.setClickShortcut(KeyCode.ENTER);
this.buttonSave.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
try {
//
// Commit it
//
self.textFieldID.commit();
//
// Save it
//
self.variable.setVariableId(self.textFieldID.getValue());
self.isSaved = true;
//
// Close window
//
self.close();
} catch (SourceException | InvalidValueException e) {
}
}
});
}