本文整理汇总了Java中org.apache.wicket.validation.IValidatable.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java IValidatable.getValue方法的具体用法?Java IValidatable.getValue怎么用?Java IValidatable.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.validation.IValidatable
的用法示例。
在下文中一共展示了IValidatable.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String title = validatable.getValue();
if (!Strings.isNullOrEmpty(title)) {
DSLContext context = Spring.getBean(DSLContext.class);
LayoutTable table = Tables.LAYOUT.as("table");
int count = 0;
if (Strings.isNullOrEmpty(this.documentId)) {
count = context.selectCount().from(table).where(table.TITLE.eq(title)).fetchOneInto(int.class);
} else {
count = context.selectCount().from(table).where(table.TITLE.eq(title)).and(table.LAYOUT_ID.notEqual(this.documentId)).fetchOneInto(int.class);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
}
}
示例2: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String title = validatable.getValue();
if (!Strings.isNullOrEmpty(title)) {
DSLContext context = Spring.getBean(DSLContext.class);
SectionTable table = Tables.SECTION.as("table");
int count = 0;
if (Strings.isNullOrEmpty(this.documentId)) {
count = context.selectCount().from(table).where(table.TITLE.eq(title)).fetchOneInto(int.class);
} else {
count = context.selectCount().from(table).where(table.TITLE.eq(title)).and(table.SECTION_ID.notEqual(this.documentId)).fetchOneInto(int.class);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
}
}
示例3: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String name = validatable.getValue();
if (!Strings.isNullOrEmpty(name)) {
DSLContext context = Spring.getBean(DSLContext.class);
RestTable table = Tables.REST.as("table");
int count = 0;
if (Strings.isNullOrEmpty(this.documentId)) {
count = context.selectCount().from(table).where(table.NAME.eq(name)).fetchOneInto(int.class);
} else {
count = context.selectCount().from(table).where(table.NAME.eq(name)).and(table.REST_ID.notEqual(this.documentId)).fetchOneInto(int.class);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
}
}
示例4: createObjectClassValidator
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
protected IValidator<String> createObjectClassValidator(final IModel<List<QName>> model){
return new IValidator<String>() {
@Override
public void validate(IValidatable<String> validated) {
String value = validated.getValue();
List<QName> list = model.getObject();
List<String> stringList = new ArrayList<>();
for(QName q: list){
stringList.add(q.getLocalPart());
}
if(!stringList.contains(value)){
error(createStringResource("SchemaHandlingStep.message.validationError", value).getString());
AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class);
target.add(getPageBase().getFeedbackPanel());
}
}
};
}
示例5: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<List<FileUpload>> validatable) {
for (FileUpload fileUpload : validatable.getValue()) {
String fileUploadExtension = FilenameUtils.getExtension(fileUpload.getClientFileName());
MediaType fileUploadMediaType = MediaType.fromExtension(fileUploadExtension);
if (fileUploadMediaType == null || !mediaTypes.contains(fileUploadMediaType)) {
ValidationError error = new ValidationError();
if (errorResourceKey != null) {
error.addKey(errorResourceKey);
}
error.addKey(this);
error.setVariable("extensions", Joiner.on(", ").skipNulls().join(Lists.transform(mediaTypes, new Function<MediaType, String>() {
@Override
public String apply(MediaType input) {
return input.extension();
}
})));
error.setVariable("clientFileName", fileUpload.getClientFileName());
validatable.error(error);
}
}
}
示例6: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<List<FileUpload>> validatable) {
for (FileUpload fileUpload : validatable.getValue()) {
Bytes fileSize = Bytes.bytes(fileUpload.getSize());
if (fileSize.greaterThan(maximum)) {
ValidationError error = new ValidationError();
if (errorResourceKey != null) {
error.addKey(errorResourceKey);
}
error.addKey(this);
error.setVariable("maximum", maximum);
error.setVariable("clientFileName", fileUpload.getClientFileName());
error.setVariable("size", fileSize);
validatable.error(error);
}
}
}
示例7: onValidate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
protected void onValidate(IValidatable<String> validatable) {
final String value = validatable.getValue();
if (value == null) return;
try {
new URILocator(value);
} catch (Exception e) {
String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null,
new Model<Serializable>(new Serializable() {
@SuppressWarnings("unused")
public String getValue() {
return value;
}
}));
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
}
}
示例8: onValidate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
protected void onValidate(IValidatable<String> validatable) {
final String value = validatable.getValue();
final String regex = getRegex();
if (value == null) return;
try {
if (value.matches(regex))
return;
else
reportError(resourceKeyInvalidValue(), value, regex);
} catch (PatternSyntaxException e) {
reportError(resourceKeyInvalidRegex(), value, regex);
}
}
示例9: onValidate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
protected void onValidate(IValidatable<String> validatable) {
final String value = validatable.getValue();
if (value == null) return;
try {
DateFormat df = createDateFormat();
df.parse(value);
} catch (ParseException e) {
String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null,
new Model<Serializable>(new Serializable() {
@SuppressWarnings("unused")
public String getValue() {
return value;
}
}));
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
}
}
示例10: onValidate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
protected void onValidate(IValidatable<String> arg0) {
String range = arg0.getValue();
for (int i = 0; i < range.length(); i++) {
char c = range.charAt(i);
if (0x20 > c) {
invalidChar = c;
error(arg0);
} else if (0xFF < c) {
invalidChar = c;
error(arg0);
}
}
}
示例11: onValidate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
protected void onValidate(IValidatable<String> arg0) {
String range = arg0.getValue();
try {
if (range != null) {
range = Util.formatRange(range);
}
InventoryUtil.checkRange(range, this.allowZero);
} catch (InventoryException e) {
this.errorMessage = e.getMessage();
error(arg0);
}
}
示例12: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String script = validatable.getValue();
if (!Strings.isNullOrEmpty(script)) {
if (script.length() >= "SELECT".length() && script.substring(0, "SELECT".length()).toLowerCase().equals("select")) {
} else {
validatable.error(new ValidationError(this, "format"));
}
}
}
示例13: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String name = validatable.getValue();
if (!Strings.isNullOrEmpty(name)) {
if (!Application.CHARACTERS.contains(name.charAt(0))) {
validatable.error(new ValidationError(this, "invalid"));
return;
}
if (name.length() > 1) {
for (int i = 1; i < name.length(); i++) {
char ch = name.charAt(i);
if (ch != '_' && !Application.CHARACTERS.contains(ch) && !Application.NUMBERS.contains(ch)) {
validatable.error(new ValidationError(this, "invalid"));
return;
}
}
}
int count = 0;
DSLContext context = Spring.getBean(DSLContext.class);
CollectionTable table = Tables.COLLECTION.as("table");
if (Strings.isNullOrEmpty(this.documentId)) {
count = context.selectCount().from(table).where(table.NAME.eq(name)).fetchOneInto(int.class);
} else {
count = context.selectCount().from(table).where(table.NAME.eq(name)).and(table.COLLECTION_ID.notEqual(this.documentId)).fetchOneInto(int.class);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
}
}
示例14: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
String path = validatable.getValue();
if (!Strings.isNullOrEmpty(path)) {
if (StringUtils.startsWithIgnoreCase(path, "/api") || StringUtils.equalsIgnoreCase(path, "/")) {
validatable.error(new ValidationError(this, "invalid"));
return;
}
if (path.length() > 1) {
for (int i = 1; i < path.length(); i++) {
char ch = path.charAt(i);
if (ch == '/' || Application.CHARACTERS.contains(ch) || Application.NUMBERS.contains(ch)) {
} else {
validatable.error(new ValidationError(this, "invalid"));
return;
}
}
}
if (StringUtils.containsIgnoreCase(path, "//")) {
validatable.error(new ValidationError(this, "invalid"));
return;
}
DSLContext context = Spring.getBean(DSLContext.class);
PageTable table = Tables.PAGE.as("table");
int count = 0;
if (Strings.isNullOrEmpty(this.documentId)) {
count = context.selectCount().from(table).where(table.PATH.eq(path)).fetchOneInto(int.class);
} else {
count = context.selectCount().from(table).where(table.PATH.eq(path)).and(table.PAGE_ID.notEqual(this.documentId)).fetchOneInto(int.class);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
}
}
示例15: validate
import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<T> validatable) {
T value = validatable.getValue();
Object newValue = null;
if (value != null) {
if (value instanceof Item) {
newValue = ((Item) value).getId();
} else {
newValue = value;
}
}
if (newValue != null) {
try {
JdbcTemplate jdbcTemplate = Spring.getBean(JdbcTemplate.class);
int count = 0;
if (this.idFieldValue == null) {
count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM " + this.tableName + " WHERE " + this.fieldName + " = ?", int.class, newValue);
} else {
count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM " + this.tableName + " WHERE " + this.fieldName + " = ? AND " + this.idFieldName + " != ?", int.class, newValue, this.idFieldValue);
}
if (count > 0) {
validatable.error(new ValidationError(this, "duplicated"));
}
} catch (BadSqlGrammarException e) {
validatable.error(new ValidationError(this, "error").setVariable("message", e.getMessage()));
}
}
}