question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RouteConfiguration.forSessionScope().getUrl() does not return scheme and domain name

See original GitHub issue

Description of the bug

The method RouteConfiguration.forSessionScope().getUrl() only returns the route and not a valid URL.

Expected behavior

Since the method RouteConfiguration.forSessionScope().getUrl() is named getUrl(), I expected it to return at least the scheme + host

https://datatracker.ietf.org/doc/html/rfc1738#section-3.3

Minimal reproducible example

@PageTitle("Static")
@Route(value = "static", layout = MainLayout.class)
@RouteAlias(value = "", layout = MainLayout.class)
@PermitAll
public class StaticView extends HorizontalLayout {

    private TextField name;
    private Button sayHello;

    public StaticView() {
        name = new TextField("Your name");
        sayHello = new Button("Say hello");
        sayHello.addClickListener(e -> {
            Notification.show("Hello " + name.getValue());
        });

        setMargin(true);
        setVerticalComponentAlignment(Alignment.END, name, sayHello);

        add(name, sayHello);

        String route = RouteConfiguration
                .forSessionScope()
                .getUrl(StaticView.class);

        System.out.println(route); //prints "static"
    }

}

Versions

  • Vaadin / Flow version: 23
  • Java version: 18
  • OS version: Windows 10
  • Browser version (if applicable): Firefox
  • Application Server (if applicable): built-in from starter project
  • IDE (if applicable): IntelliJ

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tarekorabycommented, Jun 16, 2022

The method RouteConfiguration.forSessionScope().getUrl() only returns the route parameter and not a valid URL.

Just a small nitpick, it returns the route (the one we define using @Route), not the route parameter.

0reactions
Legiothcommented, Jun 22, 2022

the route and not a valid URL

Not that it really matters in this case, but it could be noted that relative URLs are still valid URLs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

URL generation | Routing and Navigation | Flow
... the request is a simple call for RouteConfiguration.forSessionScope().getUrl(Class target). Example: Returned URL is resolved to path.
Read more >
Get domain name from given url - java
URL class) but I encountered problems with the URI class. Notably, URI.getHost() gives a null value if the url does not include the...
Read more >
Setting up custom domain names for REST APIs
Learn how to set up a custom domain name for a REST API in API Gateway. ... In this case, the custom domain...
Read more >
GitLab Pages domain names, URLs, and base URLs
On this document, learn how to name your project for GitLab Pages according to your intended website's URL. GitLab Pages default domain names....
Read more >
Google Domains – Register Your Domain Name – Google ...
Find your place online with a domain from Google, powered by Google reliability, security and performance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found