Announcement

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

    Export to PDF not working in 4.1.d?

    I'm working on updating my app from using SmartGWTEE 3.1p to 4.1d, and I am now getting an exception when trying to export a VLayout and its contents to PDF via RPCManager.exportContent(). Here is the stack trace:

    Code:
    java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method '@com.smartgwt.client.widgets.BaseWidget::getInnerHTML()': JS value of type boolean, expected java.lang.Object
    	at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:178)
    	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:271)
    	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    	at com.smartgwt.client.widgets.BaseWidget.getInnerHTML(BaseWidget.java)
    	at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    	at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    	at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    	at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
    	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    	at com.smartgwt.client.rpc.RPCManager.exportContent(RPCManager.java)
    And here is the code that called it:

    Code:
    				DSRequest requestProperties = new DSRequest();
    				requestProperties.setExportFilename(getPdfFileName());
    				requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
    				requestProperties.setContentType("application/pdf");
    				requestProperties.setDownloadResult(true);
    				RPCManager.exportContent(contentLayout, requestProperties);
    SmartClient Version: SNAPSHOT_v9.1d_2014-02-10/Enterprise Deployment (built 2014-02-10)

    Browser is FF 25.0 on Mac OSX 10.8.5.

    Any ideas?

    Thank you.

    #2
    Can you help us narrow this down - what kinds of widgets are in this VLayout?

    The best thing would of course be code that reproduces the issue.

    Comment


      #3
      There is a ton of stuff in that layout - all kinds of widgets.

      This was working fine in 3.1p, so I'm not sure what broke here.

      I cannot give you code to reproduce it - it would be a large portion of our app.

      Do you have suggestions on where to look for problems based on the error and stack trace?

      Comment


        #4
        Yeah, we just did :) Can you give us some kind of characterization of the widgets in this Layout - surely you do not have one of every kind of widget (CubeGrid, etc) in this layout so a list of involved widgets would be a good starting point.

        It would also be very helpful if you could narrow it down a little by omitting widgets of certain types and trying the export, wherever that's easy.

        Comment


          #5
          I started narrowing down what widgets were sent to print, and then started getting this error:

          Code:
          Uncaught JavaScript exception [NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot modify properties of a WrappedNative]
          Wondering if there was something wonky in my code, I modified the sample CustomDS and made a test case out of it. If I print a VLayout with Label in it, I get the error. If I comment out the Label, it prints. Here is the code:

          Code:
          package com.smartgwt.sample.client;
          
          import java.util.Date;
          
          import com.google.gwt.core.client.EntryPoint;
          import com.smartgwt.client.data.DSRequest;
          import com.smartgwt.client.rpc.RPCManager;
          import com.smartgwt.client.types.ExportDisplay;
          import com.smartgwt.client.widgets.IButton;
          import com.smartgwt.client.widgets.Label;
          import com.smartgwt.client.widgets.events.ClickEvent;
          import com.smartgwt.client.widgets.events.ClickHandler;
          import com.smartgwt.client.widgets.layout.VLayout;
          import com.smartgwt.client.widgets.layout.VStack;
          import com.smartgwt.client.widgets.toolbar.ToolStrip;
          
          /**
           * Entry point classes define <code>onModuleLoad()</code>.
           */
          public class CustomDS implements EntryPoint {
          	private IButton printButton;
          	private VLayout layout;
          
          	/**
          	 * This is the entry point method.
          	 */
          	@Override
          	public void onModuleLoad() {
          
          		VStack vStack = new VStack();
          		vStack.setLeft(175);
          		vStack.setTop(75);
          		vStack.setWidth("70%");
          		vStack.setMembersMargin(20);
          
          		layout = new VLayout();
          		layout.setHeight(100);
          		layout.setBackgroundColor("purple");
          
          		Label label = new Label();
          		label.setContents("Test Me");
          		label.setHeight(20);
          
          		// COMMENT OUT this line, and it will print!!!
          		layout.addMember(label);
          
          		vStack.addMember(layout);
          
          		ToolStrip toolbar = new ToolStrip();
          		toolbar.setMembersMargin(10);
          		toolbar.setHeight(22);
          
          		printButton = new IButton("Print");
          		printButton.addClickHandler(new ClickHandler() {
          			@Override
          			public void onClick(ClickEvent event) {
          				printMe();
          			}
          		});
          		toolbar.addMember(printButton);
          
          		vStack.addMember(toolbar);
          
          		vStack.draw();
          
          	}
          
          	/**
          	 * 
          	 */
          	protected void printMe() {
          		DSRequest requestProperties = new DSRequest();
          		requestProperties.setExportFilename("printme.pdf");
          		requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
          		requestProperties.setContentType("application/pdf");
          		requestProperties.setDownloadResult(true);
          		RPCManager.exportContent(layout, requestProperties);
          		System.out.println("printed pdf at " + new Date());
          	}
          
          }
          I hope this helps.

          Comment


            #6
            Thanks for the sample. We are actually not reproducing the problem with this sample, (running Firefox 26 on Mac OSX, testing against the 4.1d build from Feb 10)

            A couple of questions:
            - does this issue occur for you in compiled mode as well as development mode, or is it dev-mode only?
            - which version of GWT are you running?
            - how exactly is the script error manifesting? We're assuming you're seeing the warning reported in the Eclipse development mode console (correct?). Once the error occurs, does the download actually fail or does it proceed, and do you end up with a valid PDF?

            Thanks

            Isomorphic Software

            Comment


              #7
              The download fails in both development and compiled mode. I only see the error in the log when running in development mode.

              I'm using gwt 2.4.0 via the GWT_HOME environment variable.

              Here is the error in the log when running development mode, via the "ant hosted" target when in smartgwtee-4.1d/samples/custom-ds

              Code:
                   [java] === 2014-02-12 12:28:36,303 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework (SNAPSHOT_v9.1d_2014-02-10/Enterprise Deployment 2014-02-10) - Initialization Complete
                   [java] === 2014-02-12 12:28:49,502 [l0-2] INFO  Compression - /customds/sc/modules/ISC_Core.js: 908466 -> 238287 bytes
                   [java] === 2014-02-12 12:28:49,502 [l0-2] DEBUG ServletTools - setting cookie 'isc_cState' to: 'ready'
                   [java] === 2014-02-12 12:28:49,504 [l0-0] INFO  Download - Returning 304: Not modified on conditional get of: /Users/christopher.justice/Development/smartgwt/smartgwtee-4.1d/samples/custom-ds/war/customds/sc/skins/Enterprise/load_skin.js
                   [java] printed pdf at Wed Feb 12 12:28:58 MST 2014
                   [java] Uncaught JavaScript exception [NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN: Cannot modify properties of a WrappedNative] in http://127.0.0.1:8888/customds/sc/modules/ISC_Core.js, line 802
              There is no indication in the log that anything failed when I deploy the war to Tomcat.

              Comment


                #8
                The "wrapped native" error is unique to Firefox. Do you see an issue in any other browser?

                Also, can you try Firefox from some other machine to eliminate machine-specific issues or Firefox plugins as a possible cause?

                Comment


                  #9
                  It turns out that the Uncaught JavaScript exception NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN was caused by the pop-up blocker in firefox. I didn't realize it was blocking.

                  Anyway, I moved past that and started to tear down the content that was printing to find what was causing the original exception. I have a widget that extends CanvasItem to render a ListGrid in a DynamicForm. This widget seems to be the problem. It prints fine in 3.1, but not in 4.1d.

                  I've attached new test code for you. If you run it, the first error in the stack trace is the original one:

                  Code:
                       [java] java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method '@com.smartgwt.client.widgets.BaseWidget::getInnerHTML()': JS value of type boolean, expected java.lang.Object
                  Attached Files

                  Comment


                    #10
                    Great, thanks for putting together the case, we'll check it out.

                    Comment


                      #11
                      We've made a change which should address this issue.
                      Please try the next nightly build, dated Feb 14 or above

                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        I tried the nightly build from 2014-02-18 and it does fix the problem. Thank you for the defect fix.

                        Kind Regards,
                        Chris

                        Comment

                        Working...
                        X