Example usage for com.vaadin.server UICreateEvent getUiId

List of usage examples for com.vaadin.server UICreateEvent getUiId

Introduction

In this page you can find the example usage for com.vaadin.server UICreateEvent getUiId.

Prototype

public Integer getUiId() 

Source Link

Document

Gets the id of the UI about to be created.

Usage

From source file:com.freebox.engeneering.application.web.common.ApplicationUIProvider.java

License:Apache License

@Override
public UI createInstance(UICreateEvent event) {
    VaadinRequest request = event.getRequest();
    Object uiBeanNameObj = request.getService().getDeploymentConfiguration()
            .getApplicationOrSystemProperty("UIBean", null);

    //Stored in VaadinSession to use it in
    // the ApplicationScope later to initialize vaadin application scope beans
    final Integer uiId = event.getUiId();
    VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId);

    if (uiBeanNameObj instanceof String) {
        String uiBeanName = uiBeanNameObj.toString();
        return (UI) ApplicationContextLocator.getBean(uiBeanName);
    }// w w w  .java2  s  .co  m
    return super.createInstance(event);
}

From source file:com.lexaden.platform.web.ApplicationUIProvider.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//from   w  w w . j a v a  2s .c o m
public UI createInstance(UICreateEvent event) {
    VaadinRequest request = event.getRequest();
    Object uiBeanNameObj = request.getService().getDeploymentConfiguration()
            .getApplicationOrSystemProperty("UIBean", null);

    //Stored in VaadinSession to use it in
    // the ApplicationScope later to initialize vaadin application scope beans
    final Integer uiId = event.getUiId();
    VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId);

    if (uiBeanNameObj instanceof String) {
        String uiBeanName = uiBeanNameObj.toString();
        return (UI) ApplicationContextLocator.getBean(uiBeanName);
    }
    return super.createInstance(event);
}

From source file:de.appblocks.vaadin.cdi.TomcatCDIUIProvider.java

License:Apache License

@Override
public UI createInstance(UICreateEvent uiCreateEvent) {
    Class<? extends UI> type = uiCreateEvent.getUIClass();
    int uiId = uiCreateEvent.getUiId();
    VaadinRequest request = uiCreateEvent.getRequest();
    Bean<?> bean = scanForBeans(type);
    String uiMapping = "";
    if (bean == null) {
        if (type.isAnnotationPresent(CDIUI.class)) {
            uiMapping = parseUIMapping(request);
            bean = getUIBeanWithMapping(uiMapping);
        } else {//from w  w w  .  ja  v a 2 s  . c  o m
            throw new IllegalStateException("UI class: " + type.getName() + " with mapping: " + uiMapping
                    + " is not annotated with CDIUI!");
        }
    }
    UIBean uiBean = new UIBean(bean, uiId);
    try {
        // Make the UIBean available to UIScopedContext when creating nested
        // injected objects
        CurrentInstance.set(UIBean.class, uiBean);
        return (UI) getBeanManager().getReference(uiBean, type, getBeanManager().createCreationalContext(bean));
    } finally {
        CurrentInstance.set(UIBean.class, null);
    }
}

From source file:fr.univlorraine.mondossierweb.MdwTouchkitUIProvider.java

License:Apache License

@Override
public UI createInstance(UICreateEvent event) {
    //Nom de la classe UI  utiliser
    String uiBeanNameObj = "";
    //Rcupration du userAgent
    String userAgent = event.getRequest().getHeader("user-agent").toLowerCase();
    // on teste que l'utilisateur est sous WP ou accde via un navigateur compatible webkit
    if (userAgent.contains("webkit") || userAgent.contains("windows phone 8")
            || userAgent.contains("windows phone 9")) {
        //On va vers la version mobile
        LOG.debug("-uiBeanNameObj = mdwTouchkitUI");
        uiBeanNameObj = "mdwTouchkitUI";
    } else {//  ww w.ja va 2s  .  c  om
        //On affiche la page proposant une redirection vers la version Desktop
        LOG.debug("-uiBeanNameObj = mdwFallbackUI");
        uiBeanNameObj = "mdwFallbackUI";
    }

    //Stored in VaadinSession to use it in
    // the ApplicationScope later to initialize vaadin application scope beans
    final Integer uiId = event.getUiId();
    VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId);

    //On retourne l'UI dcide plus haut (desktop ou mobile)
    if (uiBeanNameObj instanceof String) {
        String uiBeanName = uiBeanNameObj.toString();
        return (UI) this.getWebApplicationContext().getBean(uiBeanName);
    }
    return super.createInstance(event);
}

From source file:fr.univlorraine.mondossierweb.MdwUIProvider.java

License:Apache License

@Override
public UI createInstance(UICreateEvent event) {
    //Nom de la classe UI  utiliser
    String uiBeanNameObj = "";
    //Rcupration du userAgent
    String userAgent = event.getRequest().getHeader("user-agent").toLowerCase();

    /* Device Detection */
    Device currentDevice = DeviceUtils.getCurrentDevice((HttpServletRequest) event.getRequest());
    // on teste que l'utilisateur est sur smartphone et avec un navigateur compatible webkit ou sous WP
    if (currentDevice.isMobile() && (userAgent.contains("webkit") || userAgent.contains("windows phone 8")
            || userAgent.contains("windows phone 9"))) {
        //On affiche la page proposant une redirection vers la version Mobile
        LOG.debug("-FallbackTouchkit UI provided (" + userAgent + ")");
        uiBeanNameObj = "mdwFallbackTouchkitUI";
    } else {/*  ww  w  . ja v a  2s . c  om*/
        //On va vers la version desktop
        LOG.debug("-uiBeanNameObj = mainUI");
        uiBeanNameObj = "mainUI";
    }

    //Stored in VaadinSession to use it in
    // the ApplicationScope later to initialize vaadin application scope beans
    final Integer uiId = event.getUiId();
    VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId);

    //On retourne l'UI dcide plus haut (desktop ou mobile)
    if (uiBeanNameObj instanceof String) {
        String uiBeanName = uiBeanNameObj.toString();
        return (UI) this.getWebApplicationContext().getBean(uiBeanName);
    }
    return super.createInstance(event);
}

From source file:org.vaadin.spring.internal.UIID.java

License:Apache License

public UIID(UICreateEvent createEvent) {
    this.uiId = createEvent.getUiId();
}

From source file:org.vaadin.spring.internal.VaadinUIIdentifier.java

License:Apache License

public VaadinUIIdentifier(UICreateEvent createEvent) {
    this.uiId = createEvent.getUiId();
}