Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required URL/route parameter set to null when using BeforeEnterEvent.forwardTo() #20205

Closed
eberleant opened this issue Oct 9, 2024 · 1 comment · Fixed by #20210
Closed

Comments

@eberleant
Copy link

eberleant commented Oct 9, 2024

Description of the bug

In a BeforeEnterEvent, forwarding to another view with a URL/route parameter (in the path) and query parameters results in the route parameter being set to null. This happens even if the route parameter is required.

Expected behavior

The route parameter should be set to whatever is indicated by the location/path that's being forwarded to.

Minimal reproducible example

View 1:

@Route("")
public class MainView extends VerticalLayout implements BeforeEnterObserver {
    @Override
    public void beforeEnter(BeforeEnterEvent event) {
        event.forwardTo("second/foo", QueryParameters.empty());
    }
}

View 2:

@Route("second")
public class SecondView extends VerticalLayout implements HasUrlParameter<String> {
    @Override
    public void setParameter(BeforeEvent event, String parameter) {
        add("URL Parameter Value: " + parameter);
    }
}

After going to View 1, you should be forwarded to View 2 with route parameter "foo". However, the route parameter is null. This is also reproducible using BeforeEnterEvent.rerouteTo() (instead of forwardTo()).

If you remove QueryParameters.empty() from the call to forwardTo(), it works as expected.

Example project: missing-url-param.zip

Versions

  • Vaadin / Flow version: 24.4.8, 24.4.13 (haven't tested other versions)
  • Java version: 17
  • OS version: N/A
  • Browser version (if applicable): Tested on Chrome, Firefox, and Safari
  • Application Server (if applicable): Jetty 11, 12
  • IDE (if applicable): N/A
@eberleant eberleant changed the title URL/route parameter set to null when using BeforeEnterEvent.forwardTo() Required URL/route parameter set to null when using BeforeEnterEvent.forwardTo() Oct 9, 2024
@tepi tepi added the BFP Bugfix priority, also known as Warranty label Oct 10, 2024
vaadin-bot added a commit that referenced this issue Oct 10, 2024
vaadin-bot added a commit that referenced this issue Oct 10, 2024
vaadin-bot added a commit that referenced this issue Oct 10, 2024
…y parameters (#20210) (CP: 24.3) (#20223)

* fix: resolve route parameters when rerouting and forwardin with query parameters (#20210)

Fixes #20205

* format code

---------

Co-authored-by: Marco Collovati <[email protected]>
mcollovati pushed a commit that referenced this issue Oct 10, 2024
@vaadin-bot
Copy link
Collaborator

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

mshabarov pushed a commit that referenced this issue Oct 16, 2024
mshabarov pushed a commit that referenced this issue Oct 16, 2024
mshabarov pushed a commit that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants