javax.validation.executable.ExecutableType Java Examples

The following examples show how to use javax.validation.executable.ExecutableType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BValInterceptor.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void initClassConfig(Class<?> targetClass) {
    if (classConfiguration == null) {
        synchronized (this) {
            if (classConfiguration == null) {
                final AnnotatedType<?> annotatedType = CDI.current().getBeanManager()
                        .createAnnotatedType(targetClass);

                if (annotatedType.isAnnotationPresent(ValidateOnExecution.class)) {
                    // implicit does not apply at the class level:
                    classConfiguration = ExecutableTypes.interpret(
                            removeFrom(Arrays.asList(annotatedType.getAnnotation(ValidateOnExecution.class).type()),
                                    ExecutableType.IMPLICIT));
                } else {
                    classConfiguration = globalConfiguration.getGlobalExecutableTypes();
                }
            }
        }
    }
}
 
Example #2
Source File: ValidatorBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
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,
                              final String clockProviderClassName,
                              final Set<String> valueExtractorClassNames) {
    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;
    this.clockProviderClassName = clockProviderClassName;
    this.valueExtractorClassNames = valueExtractorClassNames;
}
 
Example #3
Source File: PersonController.java    From tomee with Apache License 2.0 6 votes vote down vote up
@POST
@Path("update")
@ValidateOnExecution(type = ExecutableType.NONE)
public String update(@Valid @BeanParam Person person) {
    if (bindingResult.isFailed()) {

        this.getErros();
        this.models.put("countries", getCountries());
        this.models.put("person", person);
        return "change.jsp";

    }
    repository.save(person);
    message.setMessageRedirect("The " + person.getName() + " was changed successfully ! ");
    return "redirect:mvc/show";
}
 
Example #4
Source File: PersonController.java    From tomee with Apache License 2.0 6 votes vote down vote up
@POST
@Path("add")
@ValidateOnExecution(type = ExecutableType.NONE)
public String add(@Valid @BeanParam Person person) {
    if (bindingResult.isFailed()) {

        this.getErros();
        this.models.put("countries", getCountries());
        this.models.put("person", person);
        return "insert.jsp";

    }
    repository.save(person);
    message.setMessageRedirect("The " + person.getName() + " was successfully registered ! ");
    return "redirect:mvc/show";
}
 
Example #5
Source File: PersonController.java    From tomee with Apache License 2.0 6 votes vote down vote up
@POST
@Path("update")
@ValidateOnExecution(type = ExecutableType.NONE)
public String update(@Valid @BeanParam Person person) {
    if (bindingResult.isFailed()) {

        this.getErros();
        this.models.put("countries", getCountries());
        this.models.put("person", person);
        return "change.jsp";

    }
    repository.save(person);
    message.setMessageRedirect("The " + person.getName() + " was changed successfully ! ");
    return "redirect:mvc/show";
}
 
Example #6
Source File: ApplicantResourceController.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@CsrfProtected
@ServeResourceMethod(portletNames = { "portlet1" }, resourceID = "deleteFile")
@ValidateOnExecution(type = ExecutableType.NONE)
public void deleteFile(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

	PortletSession portletSession = resourceRequest.getPortletSession();

	List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());

	ResourceParameters resourceParameters = resourceRequest.getResourceParameters();

	String attachmentIndex = resourceParameters.getValue(resourceResponse.getNamespace() + "attachmentIndex");

	if (attachmentIndex != null) {
		Attachment attachment = attachments.remove(Integer.valueOf(attachmentIndex).intValue());

		try {
			File file = attachment.getFile();
			file.delete();
			_writeTabularJSON(resourceResponse.getWriter(), attachments);
		}
		catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
	}
}
 
Example #7
Source File: PersonController.java    From tomee with Apache License 2.0 6 votes vote down vote up
@POST
@Path("add")
@ValidateOnExecution(type = ExecutableType.NONE)
public String add(@Valid @BeanParam Person person) {
    if (bindingResult.isFailed()) {

        this.getErros();
        this.models.put("countries", getCountries());
        this.models.put("person", person);
        return "insert.jsp";

    }
    repository.save(person);
    message.setMessageRedirect("The " + person.getName() + " was successfully registered ! ");
    return "redirect:mvc/show";
}
 
Example #8
Source File: AbstractValidationInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message message) {
    final Object theServiceObject = getServiceObject(message);
    if (theServiceObject == null) {
        return;
    }

    final Method method = getServiceMethod(message);
    if (method == null) {
        return;
    }
    
    ValidateOnExecution validateOnExec = method.getAnnotation(ValidateOnExecution.class);
    if (validateOnExec != null) {
        ExecutableType[] execTypes = validateOnExec.type();
        if (execTypes.length == 1 && execTypes[0] == ExecutableType.NONE) {
            return;
        }
    }


    final List< Object > arguments = MessageContentsList.getContentsList(message);

    handleValidation(message, theServiceObject, method, arguments);

}
 
Example #9
Source File: ApplicantResourceController.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@CsrfProtected
@ServeResourceMethod(portletNames = { "portlet1" }, resourceID = "deleteFile")
@ValidateOnExecution(type = ExecutableType.NONE)
public void deleteFile(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

	PortletSession portletSession = resourceRequest.getPortletSession();

	List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());

	ResourceParameters resourceParameters = resourceRequest.getResourceParameters();

	String attachmentIndex = resourceParameters.getValue(resourceResponse.getNamespace() + "attachmentIndex");

	if (attachmentIndex != null) {
		Attachment attachment = attachments.remove(Integer.valueOf(attachmentIndex).intValue());

		try {
			File file = attachment.getFile();
			file.delete();
			_writeTabularJSON(resourceResponse.getWriter(), attachments);
		}
		catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
	}
}
 
Example #10
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "reset")
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfProtected
public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	try {

		Enumeration<String> preferenceNames = portletPreferences.getNames();

		while (preferenceNames.hasMoreElements()) {
			String preferenceName = preferenceNames.nextElement();

			if (!portletPreferences.isReadOnly(preferenceName)) {
				portletPreferences.reset(preferenceName);
			}
		}

		portletPreferences.store();
		actionResponse.setPortletMode(PortletMode.VIEW);
		actionResponse.setWindowState(WindowState.NORMAL);
		models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
	}
	catch (Exception e) {

		models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));

		logger.error(e.getMessage(), e);
	}
}
 
Example #11
Source File: BValInterceptor.java    From tomee with Apache License 2.0 5 votes vote down vote up
private <T> boolean computeIsConstructorValidated(Class<T> targetClass, Constructor<T> ctor) {
    final AnnotatedType<T> annotatedType =
            CDI.current().getBeanManager().createAnnotatedType(ctor.getDeclaringClass());

    final ValidateOnExecution annotation =
            annotatedType.getConstructors().stream().filter(ac -> ctor.equals(ac.getJavaMember())).findFirst()
                    .map(ac -> ac.getAnnotation(ValidateOnExecution.class))
                    .orElseGet(() -> ctor.getAnnotation(ValidateOnExecution.class));

    final Set<ExecutableType> validatedExecutableTypes =
            annotation == null ? classConfiguration : ExecutableTypes.interpret(annotation.type());

    return validatedExecutableTypes.contains(ExecutableType.CONSTRUCTORS);
}
 
Example #12
Source File: BValInterceptor.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static Collection<ExecutableType> removeFrom(Collection<ExecutableType> coll,
                                                     ExecutableType... executableTypes) {
    Validate.notNull(coll, "collection was null");
    if (!(coll.isEmpty() || ObjectUtils.isEmptyArray(executableTypes))) {
        final List<ExecutableType> toRemove = Arrays.asList(executableTypes);
        if (!Collections.disjoint(coll, toRemove)) {
            final Set<ExecutableType> result = EnumSet.copyOf(coll);
            result.removeAll(toRemove);
            return result;
        }
    }
    return coll;
}
 
Example #13
Source File: ApplicantResourceController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@CsrfProtected
@ServeResourceMethod(portletNames = { "portlet1" }, resourceID = "uploadFiles")
@ValidateOnExecution(type = ExecutableType.NONE)
public void uploadFiles(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

	PortletSession portletSession = resourceRequest.getPortletSession(true);
	List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());

	try {
		Collection<Part> transientMultipartFiles = resourceRequest.getParts();

		if (!transientMultipartFiles.isEmpty()) {

			File attachmentDir = attachmentManager.getAttachmentDir(portletSession.getId());

			if (!attachmentDir.exists()) {
				attachmentDir.mkdir();
			}

			for (Part transientMultipartFile : transientMultipartFiles) {

				String submittedFileName = transientMultipartFile.getSubmittedFileName();

				if (submittedFileName != null) {
					File copiedFile = new File(attachmentDir, submittedFileName);

					transientMultipartFile.write(copiedFile.getAbsolutePath());

					attachments.add(new Attachment(copiedFile));
				}
			}

			_writeTabularJSON(resourceResponse.getWriter(), attachments);
		}
	}
	catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
}
 
Example #14
Source File: ApplicantRenderController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@RenderMethod(portletNames = { "portlet1" })
@ValidateOnExecution(type = ExecutableType.NONE)
public String prepareView(RenderRequest renderRequest, RenderResponse renderResponse) {

	String viewName = viewEngineContext.getView();

	if (viewName == null) {

		viewName = "applicant.jspx";

		Applicant applicant = (Applicant) models.get("applicant");

		if (applicant == null) {
			applicant = new Applicant();
			models.put("applicant", applicant);
		}

		PortletSession portletSession = renderRequest.getPortletSession();
		List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());
		applicant.setAttachments(attachments);

		String datePattern = portletPreferences.getValue("datePattern", null);

		models.put("jQueryDatePattern", _getJQueryDatePattern(datePattern));

		models.put("provinces", provinceService.getAllProvinces());

		CDI<Object> currentCDI = CDI.current();
		BeanManager beanManager = currentCDI.getBeanManager();
		Class<? extends BeanManager> beanManagerClass = beanManager.getClass();
		Package beanManagerPackage = beanManagerClass.getPackage();
		models.put("weldVersion", beanManagerPackage.getImplementationVersion());
	}

	return viewName;
}
 
Example #15
Source File: PreferencesRenderController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@RenderMethod(portletNames = { "portlet1" }, portletMode = "edit")
@ValidateOnExecution(type = ExecutableType.NONE)
@View("preferences.jspx")
public void prepareView() {

	Map<String, Object> modelsMap = models.asMap();

	if (!modelsMap.containsKey("preferences")) {
		models.put("preferences", new Preferences(portletPreferences.getValue("datePattern", null)));
	}
}
 
Example #16
Source File: ApplicantResourceController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@CsrfProtected
@ServeResourceMethod(portletNames = { "portlet1" }, resourceID = "uploadFiles")
@ValidateOnExecution(type = ExecutableType.NONE)
public void uploadFiles(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

	PortletSession portletSession = resourceRequest.getPortletSession(true);
	List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());

	try {
		Collection<Part> transientMultipartFiles = resourceRequest.getParts();

		if (!transientMultipartFiles.isEmpty()) {

			File attachmentDir = attachmentManager.getAttachmentDir(portletSession.getId());

			if (!attachmentDir.exists()) {
				attachmentDir.mkdir();
			}

			for (Part transientMultipartFile : transientMultipartFiles) {

				String submittedFileName = transientMultipartFile.getSubmittedFileName();

				if (submittedFileName != null) {
					File copiedFile = new File(attachmentDir, submittedFileName);

					transientMultipartFile.write(copiedFile.getAbsolutePath());

					attachments.add(new Attachment(copiedFile));
				}
			}

			_writeTabularJSON(resourceResponse.getWriter(), attachments);
		}
	}
	catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
}
 
Example #17
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "reset")
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfProtected
public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	try {

		Enumeration<String> preferenceNames = portletPreferences.getNames();

		while (preferenceNames.hasMoreElements()) {
			String preferenceName = preferenceNames.nextElement();

			if (!portletPreferences.isReadOnly(preferenceName)) {
				portletPreferences.reset(preferenceName);
			}
		}

		portletPreferences.store();
		actionResponse.setPortletMode(PortletMode.VIEW);
		actionResponse.setWindowState(WindowState.NORMAL);
		models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
	}
	catch (Exception e) {

		models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));

		logger.error(e.getMessage(), e);
	}
}
 
Example #18
Source File: ValidatorBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
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();
        info.valueExtractorClassNames = config.getValueExtractor();
        info.clockProviderClassName = config.getClockProvider();

        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());
        }
        info.constraintMappings.addAll(config.getConstraintMapping());
    }
    return info;
}
 
Example #19
Source File: PreferencesRenderController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@RenderMethod(portletNames = { "portlet1" }, portletMode = "edit")
@ValidateOnExecution(type = ExecutableType.NONE)
@View("preferences.html")
public void prepareView(RenderRequest renderRequest, RenderResponse renderResponse) {

	Map<String, Object> modelsMap = models.asMap();

	if (!modelsMap.containsKey("preferences")) {
		models.put("preferences", new Preferences(portletPreferences.getValue("datePattern", null)));
	}

	// Thymeleaf
	models.put("mainFormActionURL", renderResponse.createActionURL());
}
 
Example #20
Source File: ValidatorContextResolver.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #21
Source File: TaskController.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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.getAllErrors()
                .stream()
                .forEach((ParamError t) -> {
                    alert.addError(t.getParamName(), "", 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();
}
 
Example #22
Source File: TaskController.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@POST
@CsrfProtected
@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.getAllErrors()
                .stream()
                .forEach((ParamError t) -> {
                    alert.addError(t.getParamName(), "", 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();
}
 
Example #23
Source File: ValidatorBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public Set<ExecutableType> getDefaultValidatedExecutableTypes() {
    return validatedTypes;
}
 
Example #24
Source File: Adapter1.java    From tomee with Apache License 2.0 4 votes vote down vote up
public String marshal(ExecutableType value) {
    if (value == null) {
        return null;
    }
    return value.toString();
}
 
Example #25
Source File: Adapter1.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ExecutableType unmarshal(String value) {
    return (javax.validation.executable.ExecutableType.valueOf(value));
}
 
Example #26
Source File: BValInterceptor.java    From tomee with Apache License 2.0 4 votes vote down vote up
private <T> boolean computeIsMethodValidated(Class<T> targetClass, Method method) {
    final Signature signature = Signature.of(method);

    AnnotatedMethod<?> declaringMethod = null;

    for (final Class<?> c : Reflection.hierarchy(targetClass, Interfaces.INCLUDE)) {
        final AnnotatedType<?> annotatedType = CDI.current().getBeanManager().createAnnotatedType(c);

        final AnnotatedMethod<?> annotatedMethod = annotatedType.getMethods().stream()
                .filter(am -> Signature.of(am.getJavaMember()).equals(signature)).findFirst().orElse(null);

        if (annotatedMethod != null) {
            declaringMethod = annotatedMethod;
        }
    }
    if (declaringMethod == null) {
        return false;
    }
    final Collection<ExecutableType> declaredExecutableTypes;

    if (declaringMethod.isAnnotationPresent(ValidateOnExecution.class)) {
        final List<ExecutableType> validatedTypesOnMethod =
                Arrays.asList(declaringMethod.getAnnotation(ValidateOnExecution.class).type());

        // implicit directly on method -> early return:
        if (validatedTypesOnMethod.contains(ExecutableType.IMPLICIT)) {
            return true;
        }
        declaredExecutableTypes = validatedTypesOnMethod;
    } else {
        final AnnotatedType<?> declaringType = declaringMethod.getDeclaringType();
        if (declaringType.isAnnotationPresent(ValidateOnExecution.class)) {
            // IMPLICIT is meaningless at class level:
            declaredExecutableTypes =
                    removeFrom(Arrays.asList(declaringType.getAnnotation(ValidateOnExecution.class).type()),
                            ExecutableType.IMPLICIT);
        } else {
            final Package pkg = declaringType.getJavaClass().getPackage();
            if (pkg != null && pkg.isAnnotationPresent(ValidateOnExecution.class)) {
                // presumably IMPLICIT is likewise meaningless at package level:
                declaredExecutableTypes = removeFrom(
                        Arrays.asList(pkg.getAnnotation(ValidateOnExecution.class).type()), ExecutableType.IMPLICIT);
            } else {
                declaredExecutableTypes = null;
            }
        }
    }
    final ExecutableType methodType =
            Methods.isGetter(method) ? ExecutableType.GETTER_METHODS : ExecutableType.NON_GETTER_METHODS;

    return Optional.ofNullable(declaredExecutableTypes).map(ExecutableTypes::interpret)
            .orElse(globalConfiguration.getGlobalExecutableTypes()).contains(methodType);
}
 
Example #27
Source File: BookStoreWithValidation.java    From cxf with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/booksValidate")
@ValidateOnExecution(type = ExecutableType.IMPLICIT)
public Response addBookValidate(@NotNull @FormParam("id") String id) {
    return Response.ok().build();
}
 
Example #28
Source File: BookStoreWithValidation.java    From cxf with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/booksNoValidate")
@ValidateOnExecution(type = ExecutableType.NONE)
public Response addBookNoValidation(@NotNull @FormParam("id") String id) {
    return Response.ok().build();
}
 
Example #29
Source File: ApplicantRenderController.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@RenderMethod(portletNames = { "portlet1" })
@ValidateOnExecution(type = ExecutableType.NONE)
public String prepareView(RenderRequest renderRequest, RenderResponse renderResponse) {

	String viewName = viewEngineContext.getView();

	if (viewName == null) {

		viewName = "applicant.html";

		Applicant applicant = (Applicant) models.get("applicant");

		if (applicant == null) {
			applicant = new Applicant();
			models.put("applicant", applicant);
		}

		PortletSession portletSession = renderRequest.getPortletSession();
		List<Attachment> attachments = attachmentManager.getAttachments(portletSession.getId());
		applicant.setAttachments(attachments);

		String datePattern = portletPreferences.getValue("datePattern", null);

		models.put("jQueryDatePattern", _getJQueryDatePattern(datePattern));

		models.put("provinces", provinceService.getAllProvinces());

		CDI<Object> currentCDI = CDI.current();
		BeanManager beanManager = currentCDI.getBeanManager();
		Class<? extends BeanManager> beanManagerClass = beanManager.getClass();
		Package beanManagerPackage = beanManagerClass.getPackage();
		models.put("weldVersion", beanManagerPackage.getImplementationVersion());

		// Thymeleaf
		models.put("autoFillResourceURL", ControllerUtil.createResourceURL(renderResponse, "autoFill"));
		models.put("deleteFileResourceURL", ControllerUtil.createResourceURL(renderResponse, "deleteFile"));
		models.put("mainFormActionURL", renderResponse.createActionURL());
		models.put("viewTermsResourceURL", ControllerUtil.createResourceURL(renderResponse, "viewTerms"));
		models.put("uploadFilesResourceURL", ControllerUtil.createResourceURL(renderResponse, "uploadFiles"));
	}

	return viewName;
}
 
Example #30
Source File: DefaultValidatedExecutableTypesType.java    From tomee with Apache License 2.0 3 votes vote down vote up
/**
 * Gets the value of the executableType property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the executableType property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getExecutableType().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link String }
 * 
 * 
 */
public List<ExecutableType> getExecutableType() {
    if (executableType == null) {
        executableType = new ArrayList<ExecutableType>();
    }
    return this.executableType;
}