Search in sources :

Example 26 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class NavigationRpcHandlerTest method handleHistoryChange_uiIsInert_navigationTriggered.

@Test
public void handleHistoryChange_uiIsInert_navigationTriggered() {
    ui.addModal(new RouterLink());
    rpcHandler.handle(ui, invocation);
    Mockito.verify(historyStateChangeHandler, Mockito.times(1)).onHistoryStateChange(Mockito.any(History.HistoryStateChangeEvent.class));
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Test(org.junit.Test)

Example 27 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class RootNavigationTarget method onAttach.

@Override
protected void onAttach(AttachEvent attachEvent) {
    Label label = new Label(String.valueOf(getUI().get().getUIId()));
    label.setId("ui-id");
    add(label);
    RouterLink link = new RouterLink("foo", FooNavigationTarget.class);
    link.setId("foo");
    add(link);
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Label(com.vaadin.flow.component.html.Label)

Example 28 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class BeansWithNoOwnerView method onAttach.

@Override
protected void onAttach(AttachEvent attachEvent) {
    NativeButton button = new NativeButton("switch content", ev -> {
        remove(current);
        if (isSubDiv) {
            current = context.getBean(ButtonNoOwner.class);
        } else {
            current = context.getBean(DivNoOwner.class);
        }
        add(current);
        isSubDiv = !isSubDiv;
    });
    button.setId("switch-content");
    add(button);
    RouterLink link = new RouterLink("another-view", AnotherBeanNopOwnerView.class);
    link.getElement().getStyle().set("display", "block");
    link.setId("navigate-another");
    add(link);
    current = context.getBean(ButtonNoOwner.class);
    add(current);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) RouterLink(com.vaadin.flow.router.RouterLink)

Example 29 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class ChildNoOwnerView method onAttach.

@Override
protected void onAttach(AttachEvent attachEvent) {
    if (attachEvent.isInitialAttach()) {
        RouterLink link = new RouterLink("parent", ParentNoOwnerView.class);
        link.setId("to-parent");
        add(link);
        Div div = new Div();
        div.setId("child-info");
        div.getElement().getStyle().set("display", "block");
        div.setText(bean.getValue());
        add(div);
    }
}
Also used : Div(com.vaadin.flow.component.html.Div) RouterLink(com.vaadin.flow.router.RouterLink)

Example 30 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class MainView method createTab.

private static Tab createTab(String text, Class<? extends Component> navigationTarget) {
    final Tab tab = new Tab();
    tab.add(new RouterLink(text, navigationTarget));
    ComponentUtil.setData(tab, Class.class, navigationTarget);
    return tab;
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Tab(com.vaadin.flow.component.tabs.Tab)

Aggregations

RouterLink (com.vaadin.flow.router.RouterLink)30 Test (org.junit.Test)23 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 TestComponent (com.vaadin.flow.component.ComponentTest.TestComponent)3 Element (com.vaadin.flow.dom.Element)3 MockUI (com.vaadin.tests.util.MockUI)3 Component (com.vaadin.flow.component.Component)2 Div (com.vaadin.flow.component.html.Div)2 DependencyList (com.vaadin.flow.component.internal.DependencyList)2 PendingJavaScriptInvocation (com.vaadin.flow.component.internal.PendingJavaScriptInvocation)2 Registration (com.vaadin.flow.shared.Registration)2 Dependency (com.vaadin.flow.shared.ui.Dependency)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 ComponentUtil (com.vaadin.flow.component.ComponentUtil)1 HasComponents (com.vaadin.flow.component.HasComponents)1 Tag (com.vaadin.flow.component.Tag)1 UI (com.vaadin.flow.component.UI)1 DnDUtilHelper (com.vaadin.flow.component.dnd.internal.DnDUtilHelper)1