java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.orderedlayout.VerticalLayout>
de.codecamp.vaadin.security.spring.util.RedirectView
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.router.BeforeEnterObserver, com.vaadin.flow.router.internal.BeforeEnterHandler, Serializable

@Route("redirect") public class RedirectView extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.orderedlayout.VerticalLayout> implements com.vaadin.flow.router.BeforeEnterObserver
Vaadin does not offer a way to redirect to a(n external) URL (as opposed to another view). Page.setLocation(String) would work, but does not prevent the original target view from being shown first. So this class provides a workaround until issue #4606 is implemented in Vaadin.

Simply call redirectToUrl(BeforeEnterEvent, String) to redirect to a URL.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event)
     
    static void
    redirectToUrl(com.vaadin.flow.router.BeforeEnterEvent event, String targetUrl)
     

    Methods inherited from class com.vaadin.flow.component.Composite

    getChildren, getContent, getElement, initContent

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener
  • Field Details

  • Constructor Details

    • RedirectView

      public RedirectView()
  • Method Details

    • beforeEnter

      public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event)
      Specified by:
      beforeEnter in interface com.vaadin.flow.router.internal.BeforeEnterHandler
    • redirectToUrl

      public static void redirectToUrl(com.vaadin.flow.router.BeforeEnterEvent event, String targetUrl)