Package org.itsnat.comp.button.normal

Examples of org.itsnat.comp.button.normal.ItsNatHTMLButton


        for(int i = 0; i < model.size(); i++)
        {
            dataModel.addElement(model.get(i));
        }

        ItsNatHTMLButton addButton = (ItsNatHTMLButton)componentMgr.findItsNatComponentById("addItemFreeListCompoundId");
        addButton.addEventListener("click",this);

        ItsNatHTMLButton removeButton = (ItsNatHTMLButton)componentMgr.findItsNatComponentById("removeItemFreeListCompoundId");
        removeButton.addEventListener("click",this);
    }
View Full Code Here


        ItsNatHTMLInputReset inputReset = (ItsNatHTMLInputReset)compMgr.findItsNatComponentById("inputResetId");
        check(inputReset);
        inputReset.setLabelValue("Input Reset");

        ItsNatHTMLButton button = (ItsNatHTMLButton)compMgr.findItsNatComponentById("buttonId");
        check(button);

        ItsNatHTMLButtonLabel buttonLabel = (ItsNatHTMLButtonLabel)compMgr.findItsNatComponentById("buttonLabelId");
        check(buttonLabel);
        buttonLabel.setLabelValue("Button With Label");
View Full Code Here

        return null;
    }

    public ItsNatHTMLButton createItsNatHTMLButtonDefault(HTMLButtonElement element,NameValue[] artifacts,boolean execCreateFilters,ItsNatStfulDocComponentManagerImpl compMgr)
    {
        ItsNatHTMLButton comp = null;
        boolean doFilters = hasBeforeAfterCreateItsNatComponentListener(execCreateFilters,compMgr);
        if (doFilters) comp = (ItsNatHTMLButton)processBeforeCreateItsNatComponentListener(element,getCompType(),null,artifacts,compMgr);
        if (comp == null)
            comp = new ItsNatHTMLButtonDefaultImpl(element,artifacts,compMgr);
        if (doFilters) comp = (ItsNatHTMLButton)processAfterCreateItsNatComponentListener(comp,compMgr);
View Full Code Here

ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
final ItsNatHTMLInputFile input = (ItsNatHTMLInputFile)compMgr.createItsNatComponentById("fileUploadInputId");
final ItsNatHTMLIFrame iframe = (ItsNatHTMLIFrame)compMgr.createItsNatComponentById("fileUploadIFrameId");
final Element progressElem = doc.getElementById("progressId");

ItsNatHTMLButton button = (ItsNatHTMLButton)compMgr.createItsNatComponentById("fileUploadButtonId");
EventListener listener = new EventListener()
{
    public void handleEvent(Event evt)
    {
        ClientDocument clientDoc = ((ItsNatEvent)evt).getClientDocument();
        ItsNatTimer timer = clientDoc.createItsNatTimer();
        EventListener timerListener = new EventListener() {
            public void handleEvent(Event evt) { }   // Nothing to do, this timer just update the client with the current state of progressElem
        };
        final ItsNatTimerHandle timerHnd = timer.schedule(null,timerListener,0,1000);

        final HTMLIFrameFileUpload iframeUpload = iframe.getHTMLIFrameFileUpload(clientDoc,input.getHTMLInputElement());

        ItsNatServletRequestListener listener = new ItsNatServletRequestListener()
        {
            public void processRequest(ItsNatServletRequest request, ItsNatServletResponse response)
            {
                FileUploadRequest fileUpReq = iframeUpload.processFileUploadRequest(request, response);

                try
                {
                    ServletResponse servRes = response.getServletResponse();
                    Writer out = servRes.getWriter();
                    out.write("<html><head /><body>");
                    out.write("<p>Content Type: \"" + fileUpReq.getContentType() + "\"</p>");
                    out.write("<p>Field Name: \"" + fileUpReq.getFieldName() + "\"</p>");
                    out.write("<p>File Name: \"" + fileUpReq.getFileName() + "\"</p>");
                    out.write("<p>File Size: " + fileUpReq.getFileSize() + "</p>");
                    out.write("</body></html>");

                    long fileSize = fileUpReq.getFileSize();
                    if (fileSize == 0) return;

                    byte[] buffer = new byte[10*1024];
                    InputStream fileUp = fileUpReq.getFileUploadInputStream();
                    long count = 0;
                    int read = 0;
                    do
                    {
                        if (iframeUpload.isDisposed())
                            return;

                        try { Thread.sleep(50); }catch(InterruptedException ex){ }
                        count += read;

                        long per = (count * 100) / fileSize;
                        synchronized(itsNatDoc)
                        {
                            Text text = (Text)progressElem.getFirstChild();
                            text.setData(String.valueOf(per));
                        }

                        read = fileUp.read(buffer);
                    }
                    while (read != -1);
                }
                catch(IOException ex)
                {
                    throw new RuntimeException(ex);
                }
                finally
                {
                    synchronized(itsNatDoc)
                    {
                        timerHnd.cancel();
                    }
                }
            }
        };
        iframeUpload.addItsNatServletRequestListener(listener);
    }
};
button.addEventListener("click", listener);

    }
View Full Code Here

TOP

Related Classes of org.itsnat.comp.button.normal.ItsNatHTMLButton

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.