Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    File Upload in smartGWT

    hi,
    Someone know how to make file upload with smartGWT;
    i search in showcase i don't find.
    it's disponible with GWT but i need to make it with smartGWT.

    if some one has any suggestions ,and if it's possible or not .

    Thanks for help

    #2
    i find the solution
    thank you

    Comment


      #3
      I'm using GWTUpload. Though it is designed to work with plain GWT it can be used with S'GWT too.

      Comment


        #4
        Thanks for your reply, i will try GWTUPload

        for information i have using fileUpload of GWT and mixed it with SmartGWT Code
        and it's works.

        :)

        Comment


          #5
          GWTUPload Sample

          Hi,


          Hope you could share some code using GWTUPload with SmartGWT. I tried to include it with SmartGWT but got Assertion error on uploader.addOnFinishUploadHandler(onFinishUploaderHandler); when:

          Please Help...

          my Code:

          Code:
          SingleUploader uploader = new SingleUploader();
          uploader.addOnFinishUploadHandler(onFinishUploaderHandler);
              	
          
          // Load the url in the document and in the case of success attach it to the viewer
          private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler(){
                  public void onFinish(IUploader uploader) {
          	if (uploader.getStatus() == Status.SUCCESS){		  
                       documentForm.getField("documentUrl").setValue(uploader.fileUrl());
          	}
          }
          };

          Comment


            #6
            Help anyone?

            Comment


              #7
              hope this helps... 'though some xrefs which hopefully are not a problem to understand it... Cya Ekki
              Code:
              package com.egr.x4gpl.app.wupload.client;
              
              import gwtupload.client.IUploadStatus;
              import gwtupload.client.IUploader;
              import gwtupload.client.SingleUploader;
              import gwtupload.client.IUploader.OnChangeUploaderHandler;
              import gwtupload.client.IUploader.OnFinishUploaderHandler;
              
              import java.util.Set;
              
              import com.egr.x4gpl.smartx4.X4App;
              import com.egr.x4gpl.smartx4.util.Progress;
              import com.egr.x4gpl.ws.CBPrmType;
              import com.egr.x4gpl.ws.ServiceCB;
              import com.google.gwt.event.shared.HandlerRegistration;
              import com.google.gwt.user.client.Timer;
              import com.google.gwt.user.client.ui.Button;
              import com.google.gwt.user.client.ui.Widget;
              import com.smartgwt.client.widgets.Label;
              import com.smartgwt.client.widgets.layout.HLayout;
              
              public class GSingleUploader extends HLayout {
              	private static String IE8_FAKE_PATH = "C:\\fakepath\\";
              	
              	class UplStatus extends Label implements IUploadStatus {
              
              		public UplStatus(ServiceCB pProgCB) {
              			super();
              			mProgCB = pProgCB;
              		}
              		
              		@Override
              		public HandlerRegistration addCancelHandler(UploadCancelHandler pHandler) {
              			return null;
              		}
              
              		@Override
              		public Status getStatus() {
              			return null;
              		}
              
              		@Override
              		public Widget getWidget() {
              			return this;
              		}
              
              		@Override
              		public IUploadStatus newInstance() {
              			return null;
              		}
              
              		@Override
              		public void setCancelConfiguration(Set<CancelBehavior> pConfig) {
              			
              		}
              
              		@Override
              		public void setError(String pError) {
              			X4App.alert(pError);
              		}
              
              		@Override
              		public void setFileName(String pName) {
              		}
              
              		@Override
              		public void setI18Constants(UploadStatusConstants pStrs) {
              			
              		}
              
              		@Override
              		public void setStatus(Status pStatus) {
              			switch (pStatus) {
              			case SUCCESS:
              				mProgCB.execute(CBPrmType.PROGRESS, new Progress());
              				break;
              			}			
              		}
              
              		@Override
              		public void setStatusChangedHandler(UploadStatusChangedHandler pHandler) {
              			// TODO Auto-generated method stub
              			
              		}
              
              		@Override
              		public void setVisible(boolean b) {
              			
              		}
              
              		@Override
              		public void setProgress(int pDone, int pTotal) {
              			mProgCB.execute(CBPrmType.PROGRESS, new Progress(pDone, pTotal));
              		}
              		
              		private ServiceCB mProgCB;
              	}
              	
              	public GSingleUploader(final String pScene, final ServiceCB pStartCB, final ServiceCB pProgCB, final ServiceCB pDoneCB) {
              		setHeight(26);
              		setMembersMargin(WUPLOAD.UI_MARGIN);
              		
              		mSceneLb = new Label(X4App.i18n(X4App.APP, WUPLOAD.RES_SCENE)+":");
              		mSceneLb.setTooltip(X4App.i18n(X4App.APP, WUPLOAD.RES_SCENE_TT));
              		mSceneLb.setHeight(24);
              		mSceneLb.setIcon("x4/16/note.png");
              		mSceneLb.setBorder(WUPLOAD.UI_BORDER);
              		addMember(mSceneLb);
              		
              		final int TIMEOUT = 500;
              		
              		new Timer() {
              			@Override
              			public void run() {
              				if (mBlink == -1) {
              					mSceneLb.setIcon("x4/16/uploading.png");
              					mSceneLb.setTooltip(X4App.i18n(X4App.APP, WUPLOAD.RES_SCENE_UPL));
              					return;
              				}
              				else if (mBlink == 1) {
              					mSceneLb.setIcon("x4/16/note2.png");
              					mBlink = 0;
              				}
              				else {
              					mSceneLb.setIcon("x4/16/note.png");
              					mBlink = 1;
              				}
              				schedule(TIMEOUT);
              			}
              		}.schedule(TIMEOUT);
              		
              		UplStatus tSceneSt = new UplStatus(new ServiceCB() {
              			@Override
              			public void execute(CBPrmType pType, Object pAny) {
              				Progress tProg = (Progress)pAny;
              				if (tProg.isDone()) {
              					mSceneDone = true;
              				}
              				pProgCB.execute(CBPrmType.PROGRESS, pAny);
              			}
              		});
              		
              		Button tSceneBtn = new Button();
              		tSceneBtn.setVisible(false);
              		
              		mSceneUp = new SingleUploader(tSceneSt, tSceneBtn);
              		mSceneUp.setFileInputSize(45);
              		mSceneUp.setFileInputPrefix("X4");
              		mSceneUp.setAutoSubmit(false);
              		mSceneUp.addOnChangeUploadHandler(new OnChangeUploaderHandler() {
              			public void onChange(IUploader pUploader) {
              				if (mBlink == -1) return;
              				String tSelectedFile = mSceneUp.getFileName();
              				
              				if (tSelectedFile.contains(IE8_FAKE_PATH)) {
              					X4App.alert(X4App.i18n(X4App.APP, "Please add this Service to your Trusted Sites."));
              					tSelectedFile = tSelectedFile.substring(IE8_FAKE_PATH.length());
              				}
              				
              				if ((pScene != null && pScene.endsWith(tSelectedFile)
              						|| (pScene == null && tSelectedFile.endsWith(".o3d")))) {
              					pStartCB.execute(CBPrmType.STRING, tSelectedFile);
              				}
              				else {
              					X4App.alert(X4App.i18n(X4App.APP, "Please select an O3D File."));
              					mSceneUp.reset();
              				}
              			}
              		});
              		mSceneUp.addOnFinishUploadHandler(new OnFinishUploaderHandler() {
              			public void onFinish(IUploader pUploader) {
              				if (mSceneDone) {
              					pDoneCB.execute(CBPrmType.VOID, null);
              				}
              			}
              		});
              		
              		addMember(mSceneUp);
              		addMember(tSceneSt);
              	}
              	
              	public void submit() {
              		mBlink = -1;
              		mSceneUp.setVisible(false);
              		mSceneUp.setFileInputSize(5);
              		mSceneLb.setContents(X4App.i18n(X4App.APP, WUPLOAD.RES_SCENE_UPL));
              		mSceneLb.setWidth(400);
              		mSceneUp.submit();
              	}
              	
              	private SingleUploader mSceneUp;
              	private Label mSceneLb;
              	private boolean mSceneDone = false;
              	private int mBlink = 0;
              }

              Comment


                #8
                Will Try... Thanks!

                Comment


                  #9
                  got tomcat security exception..

                  access denied to write file to tomcat directory..

                  tomcat 6, and windows...

                  any idea how?

                  Comment


                    #10
                    Hello All!

                    I'm trying to use GWTUploader in a SmartGWT Window but, I can't be able to draw it on the window's baselayout. This is my code:
                    Code:
                    public class SubirPdfsView extends ViewBase implements SubirPdfsPresenter.Display{ // implements EntryPoint {
                    	
                    	  private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler() {
                    	    public void onFinish(IUploader uploader) {
                    	      if (uploader.getStatus() == Status.SUCCESS) {
                    	        new PreloadedImage(uploader.fileUrl(), null); 
                    	      }
                    	    }
                    	  };
                    
                    	  public SubirPdfsView(String title, int frmWidth) {
                    		super(title,frmWidth);
                    	    
                    
                    		MultiUploader defaultUploader = new MultiUploader();
                    	defaultUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
                    		defaultUploader.setMaximumFiles(10);
                    		defaultUploader.setFileInputPrefix("default");
                    		defaultUploader.setServletPath(defaultUploader.getServletPath());
                    		defaultUploader.avoidRepeatFiles(false);
                    
                    		
                    		HLayout uploaderContainer=new HLayout();
                    		uploaderContainer.setWidth100();
                    		uploaderContainer.addMember(defaultUploader);
                    		defaultUploader.setWidth("325px");
                    
                    		VLayout uploaderLayout=new VLayout();
                    		uploaderLayout.addMember(uploaderContainer);
                    		uploaderLayout.setWidth100();
                    		
                    		addChild(uploaderLayout);
                    		setHeight(400);
                    	  }
                    }
                    And I attach the image of the Window...

                    Any help?
                    Attached Files

                    Comment


                      #11
                      Try addItem instead addChild.

                      Comment


                        #12
                        Thanks! it works!


                        (PD: But, why is diferent to add in a Layout against to add in a Window in SmartGWT?)

                        Comment


                          #13
                          I've made a sample of integration SGWT with gwtupload

                          https://github.com/Jiri-Kremser/gwtupload-sample

                          Comment


                            #14
                            GWT Uploader Library

                            Note that the GWT Uploader component can also be used within a SmartGWT project:

                            http://www.moxiegroup.com/moxieapps/gwt-uploader/

                            Comment

                            Working...
                            X