Announcement

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

    Window opens when form is submitted

    Hi,

    I am using the below for my Dynamic Form.
    form.setTarget("hidden_frame");
    form.setAction("MyServlet");

    form.submitForm();

    When my servlet finishes its work (uploads the file), a new window is opened containing the response of the servlet.

    When I was using plain GWT, there was a method onSubmitComplete(FormSubmitCompleteEvent event) that should be overriden to get the event which is the response of the servlet.

    Is there any way not to open a new window, to keep the window of my application as it was and to get the response in this window as I used to do in plain GWT?

    Any help is appreciated.

    Thank you.

    #2
    I had misplaced the hidden_frame.

    I now need to send a response from the servlet to the original page.

    I found that I can use a HiddenItem in the thread:
    http://forums.smartclient.com/showth...ght=fileupload

    I got a new problem now in my servlet:
    When I use request.getParameter("callbackName"), I am getting a null value.
    I tried this for other HiddenItems in the form I submitten and got the same problem.

    Am I doing something wrong or this is an issue?

    Thank you.
    Last edited by Halabe; 22 Apr 2009, 07:35.

    Comment


      #3
      HiddenItems definitely submit values, keep looking. If you think you've found a bug, please post a standalone test case.

      Comment


        #4
        Thanks for the reply but I am still getting the issue.
        Here is my client side code:

        Code:
         
        uploadForm = new DynamicForm();
                uploadForm.setEncoding(Encoding.MULTIPART);
                UploadItem fileItem = new UploadItem("Test Image");
                fileItem.setTitleOrientation(TitleOrientation.LEFT);
                final HiddenItem callbackItem = new HiddenItem("callbackName");
                callbackItem.setName("callbackName");
        
        
                uploadForm.setTarget("hidden_frame");
                uploadForm.setAction("ImageUploadServlet");
                uploadForm.setMethod(FormMethod.POST);
        
                IButton uploadButton = new IButton("Upload...");
                uploadButton
                        .addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                            public void onClick(ClickEvent e)
                            {
                                String callbackName = JavaScriptMethodHelper
                                        .registerCallbackFunction(new JavaScriptMethodCallback() {
                                            public void execute(String obj)
                                            {
                                                uploadFinished(obj);
                                            }
        
                                        });
                                callbackItem.setValue(callbackName); 
                                                uploadForm.submitForm();
        
                            }
                        });
        
                uploadForm.setItems(fileItem, callbackItem);
        My server side code
        Code:
        String cback = (String) request.getParameter("callbackName");
        is giving a null result.

        Any ideas?

        Comment


          #5
          SmartGWT 3.0/FF9.0.1

          Suffered the same problem. I am not able to access the form values in a correctly working FileDownloadServlet that is requested by a DynamicForm submission. The parameters are send to the servlet, however the values remain empty.

          Client:
          Code:
          DynamicForm form= new DynamicForm(){{
             setMethod(FormMethod.GET);
             setAction(TARGET_URL);
             setEncoding(Encoding.NORMAL);
             setCanSubmit(true);
          
             FormItem fileItem= new HiddenItem("fileName");
             fileItem.setValue("/my/testFile.txt");
             fileItem.setDefaultValue("/my/testFile.txt");
          
             FormItem fileItem2= new HiddenItem("fileName");
             fileItem2.setValue("/my/testFile2.txt");
             fileItem2.setDefaultValue("/my/testFile2.txt");
          
             setItems(new FormItem[]{fileItem, fielItem2});
          }};
          
          System.out.println(fileItem.getValue());  //correct
          System.out.println(fileItem2.getValue());  //correct
          form.submitForm();
          Servlet:
          Code:
          public void doGet(HttpServletRequest request, HttpServletResponse response)
          {	
             String[] fileNames= request.getParameterValues("fileName");
             //Array conraining two empty string
          }
          My LGPL workarround:
          Code:
          HTMLPane downloadTarget= new HTMLPane();
          downloadTarget.setContentsType(ContentsType.PAGE);
          downloadTarget.setVisible(false);
          downloadTarget.setHeight("1px");
          downloadTarget.setWidth("1px");
          downloadTarget.setHttpMethod(SendMethod.GET);
          parent.addChild(downloadTarget);
          
          
          //and now each time a download shall take place...
          HashMap<String,List<String>> requestParams= new HashMap<String,List<String>>();
          List<String> filesToDownload= new ArrayList<String>();
          filesToDownload.add(/my/testFile.txt);
          filesToDownload.add(/my/testFile2.txt);
          requestParams.put("fileName", filesToDownload);
          
          downloadTarget.setContentsURLParams(requestParams);
          downloadTarget.setContentsURL("/path/to/servlet");	//new GET request
          Last edited by weihnachtsmann; 7 Feb 2012, 16:51.

          Comment

          Working...
          X