Example usage for com.vaadin.server Page setTitle

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

Introduction

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

Prototype

public void setTitle(String title) 

Source Link

Document

Sets the page title.

Usage

From source file:com.hack23.cia.web.impl.ui.application.CitizenIntelligenceAgencyUI.java

License:Apache License

@Override
protected void init(final VaadinRequest request) {
    VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this));
    setSizeFull();/* w ww .  j  av  a2s.  c  o m*/
    final DiscoveryNavigator navigator = new DiscoveryNavigator(this, this);
    navigator.addView("", mainView);
    setNavigator(navigator);

    final Page currentPage = Page.getCurrent();
    final String requestUrl = currentPage.getLocation().toString();
    final String language = request.getLocale().getLanguage();
    final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language);

    currentPage.setTitle(
            userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName()
                    + ":" + userConfiguration.getLanguage().getLanguageName());

    if (getSession().getUIs().isEmpty()) {
        final WebBrowser webBrowser = currentPage.getWebBrowser();

        final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
        serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());

        final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser);
        serviceRequest.setIpInformation(ipInformation);
        serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication());
        serviceRequest.setLocale(webBrowser.getLocale().toString());
        serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser));
        serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);

        final ServiceResponse serviceResponse = applicationManager.service(serviceRequest);
        LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT, requestUrl, language, ipInformation,
                webBrowser.getBrowserApplication(), serviceRequest.getSessionId(),
                serviceResponse.getResult().toString());
    }
}

From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java

License:Open Source License

private void initNavigation() {
    Navigator navigator = new AppNavigator(getUI(), appLayout);
    navigator.addView(TodoListView.ID, TodoListView.class);
    navigator.addView(DocumentsView.ID, DocumentsView.class);
    navigator.addView(RunModelView.ID, RunModelView.class);
    navigator.addView(SettingsView.ID, SettingsView.class);
    navigator.addView(TodoView.ID, TodoView.class); //expects to-do ID as parameter
    navigator.addView(DocumentView.ID, DocumentView.class); //expects document ID as parameter + optional document parameters aded as ?key=val&key=val
    navigator.addView(FormPreviewView.ID, FormPreviewView.class); //expects model instance ID + '/' + form expression as parameter

    navigator.setErrorProvider(new ViewProvider() {

        private static final long serialVersionUID = 1L;

        @Override/*  w ww  . j a  va2  s. c om*/
        public String getViewName(String viewAndParameters) {
            return viewAndParameters;
        }

        @Override
        public View getView(String viewName) {
            return new EmptyView();
        }
    });

    navigator.addViewChangeListener(new ViewChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            //update navigation menu
            String parameters = event.getParameters();
            boolean hasParameters = parameters != null && !parameters.isEmpty();
            appLayout.viewChanged(event.getViewName() + (hasParameters ? "/" + parameters : ""));

            //update page title
            View view = event.getNewView();
            Page page = event.getNavigator().getUI().getPage();
            String title = (view instanceof AppView) ? ((AppView) view).getTitle() : null;
            page.setTitle(getMessage("application.title") + (title == null ? "" : ": " + title));
        }
    });
}

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  2  s .  c o  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.ui.ScopedUI.java

License:Apache License

/**
 * Make sure you call this from sub-class overrides. The Vaadin Page is not available during the construction of
 * this class, but is available when this method is invoked. As a result, this method sets the navigator a listener
 * for URI changes and obtains the browser locale setting for initialising {@link CurrentLocale}. Both of these are
 * provided by the Vaadin Page./*from  w  w  w.j  a  v  a2s .co m*/
 *
 * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest)
 */
@Override
protected void init(VaadinRequest request) {

    VaadinSession session = getSession();
    session.setConverterFactory(converterFactory);

    // page isn't available during injected construction, so we have to do this here
    Page page = getPage();
    page.addUriFragmentChangedListener(navigator);

    setErrorHandler(errorHandler);
    session.setErrorHandler(errorHandler);
    page.setTitle(pageTitle());

    //  also loads the UserSitemap if not already loaded
    getKrailNavigator().init();

    //layout this UI, which may also create UYI components
    doLayout();

    // now that browser is active, and user sitemap loaded, and UI constructed, set up currentLocale
    currentLocale.readFromEnvironment();
    translator.translate(this);
    // Navigate to the correct start point
    String fragment = getPage().getUriFragment();
    getKrailNavigator().navigateTo(fragment);
}