Skip to content

[Vaadin Spring] RootMappedCondition not completely working #478

Closed
vaadin/flow
#13791

Description

@mixaaaa

Hi,

since spring boot 2 the relaxed property binding behavior had been changed and does not work like RootMappedCondition.class uses it at the moment. Because of that the usage of property vaadin.url-mapping does not work instead of vaadin.MappingUrl which perfectly works :)

The following example shows the usage of new property binding api which should work

	@Override
	public boolean matches(ConditionContext context,
			AnnotatedTypeMetadata metadata) {
		VaadinConfigurationProperties vaadinConfigurationProperties = Binder.get(context.getEnvironment())
				.bind("vaadin", VaadinConfigurationProperties.class)
				.orElse(null);
		if (vaadinConfigurationProperties != null) {
			return isRootMapping(vaadinConfigurationProperties.getUrlMapping());
		}
		return false;
	}

	/**
	 * Returns {@code true} if {@code mapping} is the root mapping
	 * ({@literal "/*"}).
	 * <p>
	 * The mapping is controlled via the {@code vaadin.urlMapping} property
	 * value. By default it's {@literal "/*"}.
	 *
	 * @param mapping
	 *            the mapping string to check
	 * @return {@code true} if {@code mapping} is the root mapping and
	 *         {@code false} otherwise
	 */
	public static boolean isRootMapping(String mapping) {
		if (mapping == null) {
			return true;
		}
		return mapping.trim().replaceAll("(/\\**)?$", "").isEmpty();
	}

Cheers & Thanks for your feedback,
Uwe

Activity

  1. mehdi-vaadin commented on Jan 20, 2020

    @mehdi-vaadin
    Contributor

    @mixaaaa sorry for such a late reply. It seems that you are proposing a change in RootMappedCondition here. Would you like to create a PR for it?

  2. added a commit that references this issue on May 19, 2022
    edfb93f
  3. added a commit that references this issue on May 19, 2022
    d38199b
  4. added a commit that references this issue on May 19, 2022
    c7a6613
  5. vaadin-bot commented on May 26, 2022

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 23.1.0.rc1 and is also targeting the upcoming stable 23.1.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions