Package com.ponysdk.ui.server.basic

Examples of com.ponysdk.ui.server.basic.PFileUpload


        super.onFirstShowPage();

        final PVerticalPanel panel = new PVerticalPanel();
        panel.setSpacing(10);

        final PFileUpload fileUpload = new PFileUpload();
        fileUpload.setName("my_file");
        fileUpload.addSubmitCompleteHandler(new PSubmitCompleteHandler() {

            @Override
            public void onSubmitComplete() {
                PNotificationManager.showTrayNotification("File uploaded, submit file '" + fileUpload.getFileName() + "'");
            }
        });

        fileUpload.addStreamHandler(new StreamHandler() {

            @Override
            public void onStream(final HttpServletRequest request, final HttpServletResponse response) {
                try {
                    response.setStatus(HttpServletResponse.SC_CREATED);
                    response.getWriter().print("The file was created successfully.");
                    response.flushBuffer();
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
        });

        final PButton submitButton = new PButton("Upload File");
        submitButton.showLoadingOnRequest(true);
        submitButton.setEnabledOnRequest(false);

        submitButton.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                fileUpload.submit();
            }
        });

        panel.add(fileUpload);
        panel.add(submitButton);
View Full Code Here

TOP

Related Classes of com.ponysdk.ui.server.basic.PFileUpload

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.