Package com.vaadin.ui

Examples of com.vaadin.ui.UI


        for (UIProvider p : uiProviders) {
            // Check for existing LegacyWindow
            if (p instanceof LegacyApplicationUIProvider) {
                LegacyApplicationUIProvider legacyProvider = (LegacyApplicationUIProvider) p;

                UI existingUi = legacyProvider
                        .getExistingUI(classSelectionEvent);
                if (existingUi != null) {
                    reinitUI(existingUi, request);
                    return existingUi;
                }
            }

            uiClass = p.getUIClass(classSelectionEvent);
            if (uiClass != null) {
                provider = p;
                break;
            }
        }

        if (provider == null || uiClass == null) {
            return null;
        }

        // Check for an existing UI based on window.name

        // Special parameter sent by vaadinBootstrap.js
        String windowName = request.getParameter("v-wn");

        Map<String, Integer> retainOnRefreshUIs = session
                .getPreserveOnRefreshUIs();
        if (windowName != null && !retainOnRefreshUIs.isEmpty()) {
            // Check for a known UI

            Integer retainedUIId = retainOnRefreshUIs.get(windowName);

            if (retainedUIId != null) {
                UI retainedUI = session.getUIById(retainedUIId.intValue());
                if (uiClass.isInstance(retainedUI)) {
                    reinitUI(retainedUI, request);
                    return retainedUI;
                } else {
                    getLogger().log(
                            Level.INFO,
                            "Not using retained UI in {0} because retained UI was of type {1}"
                                    + " but {2} is expected for the request.",
                            new Object[] { windowName, retainedUI.getClass(),
                                    uiClass });
                }
            }
        }

        // No existing UI found - go on by creating and initializing one

        Integer uiId = Integer.valueOf(session.getNextUIid());

        // Explicit Class.cast to detect if the UIProvider does something
        // unexpected
        UICreateEvent event = new UICreateEvent(request, uiClass, uiId);
        UI ui = uiClass.cast(provider.createInstance(event));

        // Initialize some fields for a newly created UI
        if (ui.getSession() != session) {
            // Session already set for LegacyWindow
            ui.setSession(session);
        }

        // Set thread local here so it is available in init
        UI.setCurrent(ui);

        ui.doInit(request, uiId.intValue());

        session.addUI(ui);

        // Remember if it should be remembered
        if (vaadinService.preserveUIOnRefresh(provider, event)) {
View Full Code Here


        String[] parts = uppUri.split("/", 4); // 0= UIid, 1 = cid, 2= name, 3
                                               // = sec key
        String uiId = parts[0];
        String connectorId = parts[1];
        String variableName = parts[2];
        UI uI = session.getUIById(Integer.parseInt(uiId));
        UI.setCurrent(uI);

        StreamVariable streamVariable = uI.getConnectorTracker()
                .getStreamVariable(connectorId, variableName);
        String secKey = uI.getConnectorTracker().getSeckey(streamVariable);
        if (secKey.equals(parts[3])) {

            ClientConnector source = getConnector(uI, connectorId);
            String contentType = request.getContentType();
            if (contentType.contains("boundary")) {
View Full Code Here

     * @param session
     * @throws IOException
     */
    public void handleHeartbeatRequest(VaadinRequest request,
            VaadinResponse response, VaadinSession session) throws IOException {
        UI ui = null;
        try {
            int uiId = Integer.parseInt(request
                    .getParameter(UIConstants.UI_ID_PARAMETER));
            ui = session.getUIById(uiId);
        } catch (NumberFormatException nfe) {
            // null-check below handles this as well
        }
        if (ui != null) {
            ui.setLastHeartbeatTimestamp(System.currentTimeMillis());
            // Ensure that the browser does not cache heartbeat responses.
            // iOS 6 Safari requires this (#10370)
            response.setHeader("Cache-Control", "no-cache");
        } else {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, "UI not found");
View Full Code Here

        if (key == null) {
            return error(request, response, pathInfo
                    + " is not a valid global resource path");
        }

        UI ui = session.getUIById(Integer.parseInt(uiid));
        if (ui == null) {
            return error(request, response, "No UI found for id  " + uiid);
        }
        UI.setCurrent(ui);
View Full Code Here

        int uiId = Integer.parseInt(uiIdString);

        // Get lock before accessing data in session
        session.lock();
        try {
            UI ui = session.getUIById(uiId);

            UI.setCurrent(ui);
            return ui;
        } finally {
            session.unlock();
View Full Code Here

                // UI is resolved in communication manager
                communicationManager.handleFileUpload(vaadinSession, request,
                        response);
                return;
            } else if (requestType == RequestType.UIDL) {
                UI uI = getService().findUI(request);
                if (uI == null) {
                    throw new ServletException(ERROR_NO_UI_FOUND);
                }
                // Handles AJAX UIDL requests
                communicationManager.handleUidlRequest(request, response,
View Full Code Here

        Matcher matcher = CONNECTOR_RESOURCE_PATTERN.matcher(requestPath);
        if (matcher.matches()) {
            String uiId = matcher.group(1);
            String cid = matcher.group(2);
            String key = matcher.group(3);
            UI ui = session.getUIById(Integer.parseInt(uiId));
            if (ui == null) {
                return error(request, response,
                        "Ignoring connector request for no-existent root "
                                + uiId);
            }

            UI.setCurrent(ui);
            VaadinSession.setCurrent(ui.getSession());

            ClientConnector connector = ui.getConnectorTracker().getConnector(
                    cid);
            if (connector == null) {
                return error(request, response,
                        "Ignoring connector request for no-existent connector "
                                + cid + " in root " + uiId);
View Full Code Here

                            vaadinRequest);

                    /* Notify listeners */

                    // Finds the right UI
                    UI uI = null;
                    if (requestType == RequestType.UIDL) {
                        uI = getService().findUI(vaadinRequest);
                    }

                    // TODO Should this happen before or after the transaction
View Full Code Here

    }

    /* Documentation copied from interface */
    @Override
    public void markAsDirty() {
        UI uI = getUI();
        if (uI != null) {
            uI.getConnectorTracker().markDirty(this);
        }
    }
View Full Code Here

    protected SharedState getState(boolean markAsDirty) {
        if (null == sharedState) {
            sharedState = createState();
        }
        if (markAsDirty) {
            UI ui = getUI();
            if (ui != null && !ui.getConnectorTracker().isWritingResponse()
                    && !ui.getConnectorTracker().isDirty(this)) {
                markAsDirty();
            }
        }
        return sharedState;
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.UI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.