Announcement

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

    Problem with printing

    Hello,
    I have a problem with this code :

    Code:
    final VLayout layout = new VLayout(15);
    		
    		IButton printButton = new IButton("Imprimer");   
    		printButton.addClickHandler(new ClickHandler() {   
                public void onClick(ClickEvent event) {
                	Canvas.showPrintPreview(layout);
                }   
            });
            
            layout.addMember(printButton);
    When I click on the button there is a Javascript error : "parent[...] a la valeur Null ou n'est pas un objet" ("parent[...] has a null value or is not an object" ?) and when I try a print preview, my listgrid (not in the code) which is in my layout is really odd (empty lines)

    What is the problem ?
    Is it a bug with SmartGwt or is it not the good way to print a listGrid (which has scrollbars) ?

    Thank you very much by advance

    #2
    Can you show the rest of the code, and provide a stack trace (ideally from both Firebug and the Developer Console in IE) for that JS error?

    Comment


      #3
      I can't install these tools on my PC but that is the rest of the code :

      Code:
      package org.gwtbook.client;
      
      import com.smartgwt.client.data.DataSource;
      import com.smartgwt.client.widgets.Canvas;
      import com.smartgwt.client.widgets.IButton;
      import com.smartgwt.client.widgets.events.ClickEvent;
      import com.smartgwt.client.widgets.events.ClickHandler;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.layout.VLayout;
      
      public class TransactionsProto extends ProtoSoclePanel {
      	
      	public static class Factory implements PanelFactory {
              private String id;
      
              public Canvas create() {
                  TransactionsProto panel = new TransactionsProto();
                  id = panel.getID();
                  return panel;
              }
      
              public String getID() {
                  return id;
              }
      
          }
      	
      	public Canvas getViewPanel() {
              
      		final DataSource dataSource = TransactionDS.getInstance();
      		
      		final ListGrid transactGrid = new ListGrid();
      		
      		final VLayout layout = new VLayout(15);
      		
      		IButton printButton = new IButton("Imprimer");   
      		printButton.addClickHandler(new ClickHandler() {   
                  public void onClick(ClickEvent event) {
                  	Canvas.showPrintPreview(layout);
                  }   
              });
              
              layout.addMember(printButton);
      		
      		transactGrid.setAutoFetchData(true);
      		transactGrid.groupBy("numCompte");
      		transactGrid.setGroupStartOpen("all");
      		transactGrid.setSortField("numCompte");
      		
      		transactGrid.setWidth(600);
      		transactGrid.setHeight(200);
      		transactGrid.setDataSource(dataSource);
      		transactGrid.setCanEdit(true);
      		transactGrid.setCanReorderRecords(true);
      		transactGrid.setCanAcceptDroppedRecords(true);
      		
      		layout.addMember(transactGrid);
      
      		return layout;
      		
          }
      
      	
      }
      I didn't have any problem before I add the showPrintPreviewLine

      Comment


        #4
        Behavior with IE6:
        - Error Javascript (what I said)

        Behavior with Firefox 3.0.5
        - Try to save a Jsp file ?
        Content of the Jsp file :
        Code:
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
        <HTML>
        <HEAD>
        <%-- page title is driven by main page via the 'title' parameter to this page --%>
        <TITLE><%=request.getParameter("title")%></TITLE>
        </HEAD>
        <%-- body overflow: hidden - suppress page level scrollbars --%>
        <!-- onafterprint - supported in IE only -->
        <BODY overflow="hidden" onload="pageLoaded()" onafterprint="printed()">
        
        <script>
        // document.write out our skin styles file
        if (window.parent && window.parent.isc) {
            document.write('<LINK REL="STYLESHEET" TYPE="text/css" HREF=' + 
                           window.parent.isc.Page.getURL("[SKIN]/skin_styles.css")+
                           ">");
        }
        </script>
        
        <SCRIPT>
        function pageLoaded() {
            window.controllerCanvas = '<%=request.getParameter("id")%>';
            parent[controllerCanvas].iframeLoad();
        }
        
        function printed() {
            parent[window.controllerCanvas].printComplete();
        }
        
        function assignHTML(HTML) {
            getPrintElement().innerHTML = HTML;
        }
        
        function getPrintElement() {
            return document.getElementById('printElement');
        }
        
        function doPrint(callback) {
            // focus() required for IE - otherwise it prints the top-level window
            focus();
            print();
            
        }
        
        </SCRIPT>
        
        <span id='printElement'></span>
        
        </SCRIPT>
        </BODY>
        </HTML>
        Error with Firefox :
        "parent[ControllerCanvas] is undefined"
        The error appear in the file above that is automatically generated.

        Hope it will help.

        Comment


          #5
          Do you have printFrame.jsp deployed somewhere that it can actually run (eg Tomcat)? Note there's a solution here for PHP as well.

          Comment


            #6
            A quick update: For 7.0 final we'll be removing printFrame.jsp in favor of a static printFrame.html file, which will resolve this issue regardless of how the file is deployed.

            Comment


              #7
              The latest SmartGWT build / SVN does not require a JSP anymore for the printable view.

              Sanjiv

              Comment


                #8
                Ok thank you :)

                Comment


                  #9
                  SVN Trunk cannot print

                  Dear,

                  Using the SVN Trunk (r292), the function "Canvas.showPrintPreview()" do not work any more.

                  See Showcase 'Print Grid' for example.

                  Regards.

                  Alexandre

                  Comment

                  Working...
                  X