Example usage for com.vaadin.server Page setUriFragment

List of usage examples for com.vaadin.server Page setUriFragment

Introduction

In this page you can find the example usage for com.vaadin.server Page setUriFragment.

Prototype

public void setUriFragment(String newUriFragment, boolean fireEvents) 

Source Link

Document

Sets the fragment part in the current location URI.

Usage

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudLogic.java

License:Apache License

/**
 * Update the fragment without causing navigator to change view
 *///from  w  w w.j  a  v a2s .  c om
private void setFragmentParameter(String productId) {
    String fragmentParameter;
    if (productId == null || productId.isEmpty()) {
        fragmentParameter = "";
    } else {
        fragmentParameter = productId;
    }

    Page page = MyUI.get().getPage();
    page.setUriFragment("!" + SampleCrudView.VIEW_NAME + "/" + fragmentParameter, false);
}

From source file:de.symeda.sormas.ui.caze.CaseController.java

License:Open Source License

/**
 * Update the fragment without causing navigator to change view
 *///  ww  w .  j a v a 2 s. com
public void setUriFragmentParameter(String caseUuid) {
    String fragmentParameter;
    if (caseUuid == null || caseUuid.isEmpty()) {
        fragmentParameter = "";
    } else {
        fragmentParameter = caseUuid;
    }

    Page page = SormasUI.get().getPage();
    page.setUriFragment("!" + CasesView.VIEW_NAME + "/" + fragmentParameter, false);
}

From source file:de.symeda.sormas.ui.contact.ContactController.java

License:Open Source License

/**
 * Update the fragment without causing navigator to change view
 *//* ww  w. j ava  2 s .  c  o  m*/
public void setUriFragmentParameter(String contactUuid) {
    String fragmentParameter;
    if (contactUuid == null || contactUuid.isEmpty()) {
        fragmentParameter = "";
    } else {
        fragmentParameter = contactUuid;
    }

    Page page = SormasUI.get().getPage();
    page.setUriFragment("!" + ContactsView.VIEW_NAME + "/" + fragmentParameter, false);
}

From source file:de.symeda.sormas.ui.events.EventController.java

License:Open Source License

public void setUriFragmentParameter(String eventUuid) {
    String fragmentParameter;// www  . j  a va  2 s .c o  m
    if (eventUuid == null || eventUuid.isEmpty()) {
        fragmentParameter = "";
    } else {
        fragmentParameter = eventUuid;
    }

    Page page = SormasUI.get().getPage();
    page.setUriFragment("!" + EventsView.VIEW_NAME + "/" + fragmentParameter, false);
}

From source file:de.symeda.sormas.ui.user.UserController.java

License:Open Source License

/**
 * Update the fragment without causing navigator to change view
 *///from   w  w w . j av a2  s .  co  m
public void setUriFragmentParameter(String caseUuid) {
    String fragmentParameter;
    if (caseUuid == null || caseUuid.isEmpty()) {
        fragmentParameter = "";
    } else {
        fragmentParameter = caseUuid;
    }

    Page page = SormasUI.get().getPage();
    page.setUriFragment("!" + UsersView.VIEW_NAME + "/" + fragmentParameter, false);
}

From source file:info.magnolia.ui.vaadin.magnoliashell.MagnoliaShell.java

License:Open Source License

public void setUriFragment(Fragment fragment) {
    if (fragment.isApp()) {
        getState().currentAppUriFragment = fragment;
    }/*from   w  ww.j ava  2 s. c om*/
    Page current = Page.getCurrent();
    if (current != null) {
        current.setUriFragment(fragment.toFragment(), false);
    }
}

From source file:pl.exsio.frameset.vaadin.navigation.target.TabbedNavigationTarget.java

License:Open Source License

@Autowired
public void setApplicationContext(ApplicationContext applicationContext) {
    this.applicationContext = applicationContext;
    final FramesetNavigator navigator = (FramesetNavigator) this.applicationContext
            .getBean(FramesetNavigator.NAVIGATOR_BEAN_NAME);
    this.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override/*from  w w w. java 2s. co m*/
        public void selectedTabChange(SelectedTabChangeEvent event) {
            if (updateSelection) {
                VaadinModule module = (VaadinModule) event.getTabSheet().getSelectedTab();
                Page currentPage = Page.getCurrent();
                currentPage.setUriFragment(navigator.getPath(module.getFrame()), false);
                currentPage.setTitle(t(module.getFrame().getTitle()));
            }
        }
    });
}

From source file:uk.q3c.krail.core.navigate.DefaultNavigator.java

License:Apache License

/**
 * Navigates to a the location represented by {@code navigationState}. If the {@link Sitemap} holds a redirect for
 * the URI represented by {@code navigationState}, navigation will be directed to the redirect target. An
 * unrecognised URI will throw a {@link SitemapException}. If the view for the URI is found, the user's
 * authorisation is checked. If the user is not authorised, a {@link AuthorizationException} is thrown. This would
 * be caught by the the implementation bound to {@link UnauthorizedExceptionHandler}. If the user is authorised,
 * the/*from   ww w  .  j a  v  a 2  s  . c o  m*/
 * View is instantiated, and made the current view in the UI via {@link ScopedUI#changeView(KrailView)}.<br>
 * <br>
 * Messages are published to the {{@link #eventBus}} before and after the view change. Message handlers have the
 * option to block the view change by returning false (see {@link #publishBeforeViewChange(BeforeViewChangeBusMessage)}
 * <p>
 *
 * @param navigationState
 *         The navigationState to navigate to. May not be null.
 */
@Override
public void navigateTo(NavigationState navigationState) {
    checkNotNull(navigationState);
    //computer says no
    if (!viewChangeRule.changeIsAllowed(this, currentView)) {
        return;
    }
    //makes sure the navigation state is up to date, removes the need to do this externally
    uriHandler.updateFragment(navigationState);

    redirectIfNeeded(navigationState);

    // stop unnecessary changes, but also to prevent navigation aware
    // components from causing a loop by responding to a change of URI (they should suppress events when they do,
    // but may not)
    if (navigationState == currentNavigationState) {
        log.debug("fragment unchanged, no navigation required");
        return;
    }

    // https://sites.google.com/site/q3cjava/sitemap#emptyURI
    if (navigationState.getVirtualPage().isEmpty()) {
        navigationState.setVirtualPage(userSitemap.standardPageURI(StandardPageKey.Public_Home));
        uriHandler.updateFragment(navigationState);
    }

    log.debug("obtaining view for '{}'", navigationState.getVirtualPage());

    UserSitemapNode node = userSitemap.nodeFor(navigationState);
    if (node == null) {
        InvalidURIException exception = new InvalidURIException("URI not found");
        exception.setTargetURI(navigationState.getVirtualPage());
        throw exception;
    }

    Subject subject = subjectProvider.get();
    boolean authorised = pageAccessController.isAuthorised(subject, node);
    if (authorised) {

        // need this in case the change is blocked by a listener
        NavigationState previousPreviousNavigationState = previousNavigationState;
        previousNavigationState = currentNavigationState;
        currentNavigationState = navigationState;

        BeforeViewChangeBusMessage beforeMessage = new BeforeViewChangeBusMessage(previousNavigationState,
                navigationState);
        // if change is blocked revert to previous state
        if (!publishBeforeViewChange(beforeMessage)) {
            currentNavigationState = previousNavigationState;
            previousNavigationState = previousPreviousNavigationState;
            return;
        }

        // make sure the page uri is updated if necessary, but do not fire any change events
        // as we have already responded to the change
        ScopedUI ui = uiProvider.get();
        Page page = ui.getPage();
        if (!navigationState.getFragment().equals(page.getUriFragment())) {
            page.setUriFragment(navigationState.getFragment(), false);
        }
        // now change the view
        KrailView view = viewFactory.get(node.getViewClass());
        AfterViewChangeBusMessage afterMessage = new AfterViewChangeBusMessage(beforeMessage);
        changeView(view, afterMessage);
        // and tell listeners its changed
        publishAfterViewChange(afterMessage);
    } else {
        throw new UnauthorizedException(navigationState.getVirtualPage());
    }

}