当前位置: 首页>>代码示例>>Java>>正文


Java ExecutableType类代码示例

本文整理汇总了Java中javax.validation.executable.ExecutableType的典型用法代码示例。如果您正苦于以下问题:Java ExecutableType类的具体用法?Java ExecutableType怎么用?Java ExecutableType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExecutableType类属于javax.validation.executable包,在下文中一共展示了ExecutableType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formPost

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@ValidateOnExecution(type = ExecutableType.NONE)
public Response formPost(@Valid @BeanParam FormDataBean form) {
    final BindingResult vr = getVr();
    if (vr.isFailed()) {
        ValidationError validationError = vr.getAllValidationErrors().iterator().next();
        final ConstraintViolation<?> cv = validationError.getViolation();
        final String property = cv.getPropertyPath().toString();
        error.setProperty(property.substring(property.lastIndexOf('.') + 1));
        error.setValue(cv.getInvalidValue());
        error.setMessage(cv.getMessage());
        error.setParam(validationError.getParamName());
        return Response.status(BAD_REQUEST).entity("error.jsp").build();
    }
    return Response.status(OK).entity("data.jsp").build();
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:17,代码来源:FormControllerProperty.java

示例2: formPost

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
public Response formPost(@Valid @BeanParam FormDataBean form) {
    if (br.isFailed()) {
        ValidationError validationError = br.getAllValidationErrors().iterator().next();
        final ConstraintViolation<?> cv = validationError.getViolation();
        final String property = cv.getPropertyPath().toString();
        error.setProperty(property.substring(property.lastIndexOf('.') + 1));
        error.setValue(cv.getInvalidValue());
        error.setMessage(cv.getMessage());
        error.setParam(validationError.getParamName());
        return Response.status(BAD_REQUEST).entity("error.jsp").build();
    }
    return Response.status(OK).entity("data.jsp").build();
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:17,代码来源:FormController.java

示例3: addPerson

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("/person")
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String addPerson(@BeanParam @Valid Person person) {

    if (bindingResult.isFailed()) {
        models.put("messages", bindingResult.getAllMessages());
    } else {
        dataStore.addPerson(person);
    }

    List<Person> personList = dataStore.getPersonList();
    models.put("personList", personList);

    return "person.jsp";
}
 
开发者ID:rahmanusta,项目名称:mvc-demo,代码行数:18,代码来源:PersonController.java

示例4: formPost

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@ValidateOnExecution(type = ExecutableType.NONE)
public Response formPost(@Valid @BeanParam HelloBean form) {

   if (validationResult.isFailed()) {

      validationResult.getAllViolations().stream()
              .forEach(v -> {
                 final String p = v.getPropertyPath().toString();
                 models.put(p.substring(p.lastIndexOf('.') + 1), v.getMessage());
              });

      models.put("form", form);

      return Response.status(BAD_REQUEST).entity("form.jsp").build();
   }

   models.put("name", form.getFirstName() + " " + form.getLastName());

   return Response.status(OK).entity("hello.jsp").build();
}
 
开发者ID:ivargrimstad,项目名称:javaee-mvc-spring,代码行数:22,代码来源:HelloController.java

示例5: OpenEjbBootstrapConfig

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
public OpenEjbBootstrapConfig(final String providerClassName,
                              final String constraintFactoryClass,
                              final String messageInterpolatorClass,
                              final String traversableResolverClass,
                              final String parameterNameProviderClass,
                              final Set<String> constraintMappings,
                              final boolean executableValidationEnabled,
                              final Set<ExecutableType> validatedTypes,
                              final Map<String, String> props) {
    this.providerClassName = providerClassName;
    this.constraintFactoryClass = constraintFactoryClass;
    this.messageInterpolatorClass = messageInterpolatorClass;
    this.traversableResolverClass = traversableResolverClass;
    this.parameterNameProviderClass = parameterNameProviderClass;
    this.constraintMappings = constraintMappings;
    this.executableValidationEnabled = executableValidationEnabled;
    this.validatedTypes = validatedTypes;
    this.props = props;
}
 
开发者ID:apache,项目名称:tomee,代码行数:20,代码来源:ValidatorBuilder.java

示例6: getContext

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:15,代码来源:ValidatorContextResolver.java

示例7: createProduct

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createProduct(@Valid
        @BeanParam Product entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:product/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductController.java

示例8: updateProduct

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateProduct(@Valid
        @BeanParam Product entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:product/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductController.java

示例9: createProductOrder

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createProductOrder(@Valid
        @BeanParam ProductOrder entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:productOrder/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductOrderController.java

示例10: updateProductOrder

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateProductOrder(@Valid
        @BeanParam ProductOrder entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:productOrder/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductOrderController.java

示例11: createCustomer

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createCustomer(@Valid
        @BeanParam Customer entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:customer/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:CustomerController.java

示例12: updateCustomer

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateCustomer(@Valid
        @BeanParam Customer entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:customer/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:CustomerController.java

示例13: save

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
@CsrfValid
@ValidateOnExecution(type = ExecutableType.NONE)
public Response save(@Valid @BeanParam TaskForm form) {
    log.log(Level.INFO, "saving new task @{0}", form);

    if (validationResult.isFailed()) {
        AlertMessage alert = AlertMessage.danger("Validation voilations!");
        validationResult.getAllViolations()
                .stream()
                .forEach((ConstraintViolation t) -> {
                    String path = t.getPropertyPath().toString();
                    alert.addError(path.substring(path.lastIndexOf(".") + 1), "", t.getMessage());
                });
        models.put("errors", alert);
        return Response.status(BAD_REQUEST).entity("add.jspx").build();
    }

    Task task = new Task();
    task.setName(form.getName());
    task.setDescription(form.getDescription());
    task.setDueDate(form.getDueDate());

    taskRepository.save(task);

    flashMessage.notify(Type.success, "Task was created successfully!");
    //models.put("flashMessage", flashMessage);

    return Response.ok("redirect:tasks").build();
}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:31,代码来源:TaskController.java

示例14: save

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
@POST
//@CsrfValid
@ValidateOnExecution(type = ExecutableType.NONE)
public Response save(@Valid @BeanParam TaskForm form) {
    log.log(Level.INFO, "saving new task @{0}", form);

    if (validationResult.isFailed()) {
        AlertMessage alert = AlertMessage.danger("Validation voilations!");
        validationResult.getAllViolations()
                .stream()
                .forEach((ConstraintViolation t) -> {
                    String path = t.getPropertyPath().toString();
                    alert.addError(path.substring(path.lastIndexOf(".") + 1), "", t.getMessage());
                });
        models.put("errors", alert);
        return Response.status(BAD_REQUEST).entity("add.xhtml").build();
    }

    Task task = new Task();
    task.setName(form.getName());
    task.setDescription(form.getDescription());

    taskRepository.save(task);

    flashMessage.notify(Type.success, "Task was created successfully!");
    //models.put("flashMessage", flashMessage);

    return Response.ok("redirect:tasks").build();
}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:30,代码来源:TaskController.java

示例15: getInfo

import javax.validation.executable.ExecutableType; //导入依赖的package包/类
public static ValidationInfo getInfo(final ValidationConfigType config) {
    final ValidationInfo info = new ValidationInfo();
    if (config != null) {
        info.version = config.getVersion();
        info.providerClassName = config.getDefaultProvider();
        info.constraintFactoryClass = config.getConstraintValidatorFactory();
        info.traversableResolverClass = config.getTraversableResolver();
        info.messageInterpolatorClass = config.getMessageInterpolator();
        info.parameterNameProviderClass = config.getParameterNameProvider();

        final ExecutableValidationType executableValidation = config.getExecutableValidation();
        if (executableValidation != null) {
            info.executableValidationEnabled = executableValidation.getEnabled();
            final DefaultValidatedExecutableTypesType executableTypes = executableValidation.getDefaultValidatedExecutableTypes();
            if (executableTypes != null) {
                for (final ExecutableType type : executableTypes.getExecutableType()) {
                    info.validatedTypes.add(type.name());
                }
            }
        }
        for (final PropertyType p : config.getProperty()) {
            info.propertyTypes.put(p.getName(), p.getValue());
        }
        for (final String element : config.getConstraintMapping()) {
            info.constraintMappings.add(element);
        }
    }
    return info;
}
 
开发者ID:apache,项目名称:tomee,代码行数:30,代码来源:ValidatorBuilder.java


注:本文中的javax.validation.executable.ExecutableType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。