When I print a object with styles, the result is the message:
This script is part of module com.example.example1
Why?
Thank you.
I tested following and it didn't throw any exception (in hosted mode)
Print.it();
Print.it("<link rel='StyleSheet' type='text/css'
media='paper' href='Foo.css'>",new Label("label"));
Print.it("<style type='text/css' media='paper'> .newPage
{page-break-after: always; } </style>","Hi<p class='newPage'></p>By");
Could you post some code of what you are trying to do?
Cheers,
Dominik
On 23 Mrz., 11:19, "jadiaz" <jadi...@gmail.com> wrote:
> I use the class o the messagehttp://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
When I print, normally it prints the message This script is part of
module com.example.example1 sometimes it prints of correct form.
I have tried to print 5 times, 3 times it printed the message, other
times it printed correct.
This is my code:
DataMonth.java
package com.example.client;
public class DataMonth {
public DataMonth() {
}
private String month;
public String getMonth() {
return this.month;
}
public void setMonth(String month) {
this.month = month;
}
private int number;
public int getNumber() {
return this.number;
}
public void setNumber(int number) {
this.number = number;
}
public DataMonth(String month, int number) {
this.setMonth(month);
this.setNumber(number);
}
}
DataWidget.java
package com.example.client;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import java.util.Vector;
public class DataWidget extends FlexTable {
private Vector monthData;
int xCoord = 0;
int yCoord = 0;
public DataWidget() {
super();
this.sinkEvents(Event.ONCLICK);
this.setStyleName("DataWidget");
this.setText(0,0,"Month");
this.setText(0,1,"Waiting");
this.getFlexCellFormatter().setStyleName(0,0,"header");
this.getFlexCellFormatter().setStyleName(0,1,"header");
this.addTableListener(new TableListener(){
public void onCellClicked(SourcesTableEvents sender, int
row, int cell){
PopupPanel panel = new PopupPanel(true);
panel.show();
}
});
}
public void onBrowserEvent(Event event) {
xCoord = DOM.eventGetClientX(event);
yCoord = DOM.eventGetClientY(event);
super.onBrowserEvent(event);
}
public void setData (Vector data){
int pos=0;
monthData = data;
for (int x=1; x<this.getRowCount();x++){
this.removeRow(x);
}
for (int x=0;x<data.size();x++){
DataMonth dataMonth = (DataMonth) data.elementAt(x);
this.setText(x+1,0,dataMonth.getMonth());
this.getFlexCellFormatter().setStyleName(x+1,0,"body");
this.setText(x
+1,1,Integer.toString(dataMonth.getNumber()));
this.getFlexCellFormatter().setStyleName(x+1,1,"body");
}
}
}
Example1.java
package com.example.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
import java.util.Vector;
public class Example1 implements EntryPoint {
public Example1() {
}
public void onModuleLoad() {
final DataWidget dataMonth = new DataWidget();
DataMonth month1 = new DataMonth("January",11);
DataMonth month2 = new DataMonth("February",25);
DataMonth month3 = new DataMonth("March",52);
DataMonth month4 = new DataMonth("April",15);
Vector vectorMonths = new Vector();
vectorMonths.add(month1);
vectorMonths.add(month2);
vectorMonths.add(month3);
vectorMonths.add(month4);
dataMonth.setData(vectorMonths);
RootPanel.get().add(dataMonth);
Button print = new Button("Print");
print.addClickListener(new ClickListener(){
public void onClick(Widget sender) {
Print.it("<link rel='StyleSheet' type='text/css'
href='DataWidget.css'>",dataMonth);
}
});
RootPanel.get().add(print);
}
}
DataWidget.css
.DataWidget{
width: 100%;
border: 1px solid #ACA899;
}
.DataWidget .header {
width: 100%;
color: #000000;
background-color: #C3D9FF;
padding: 0px;
}
.DataWidget .body {
width: 100%;
cursor: pointer;
}
Example1.html
<html>
<head>
<meta name='gwt:module' content='com.example.Example1'>
<link rel=stylesheet href="DataWidget.css">
<title>Example1</title>
</head>
<body>
<iframe id="__printingFrame" style="width:0;height:0;border:
0"></iframe>
<script language="javascript" src="gwt.js"></script>
</body>
</html>
bye.
jose.
On 23 mar, 13:18, "Dominik Steiner" <Dominik.Stei...@partner.bmw-
> > Thank you.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
I just tested your code, and it works fine for me here.
I'm using the corrected Print class from Andre Feller.
/**
* <pre>
* Generic printing class
* can be used to print the Window it self, DOM.Elements, UIObjects
(Widgets) and plain HTML
*
* Usage:
* You must insert this iframe in your host page:
* <iframe id="__printingFrame"
style="width:0;height:0;border:0"></iframe>
*
* Window:
* Print.it();
*
* Objects/HTML:
* Print.it(RootPanel.get("myId"));
* Print.it(DOM.getElementById("myId"));
* Print.it("Just <b>Print.it()</b>!");
*
* Objects/HTML using styles:
* Print.it("<link rel='StyleSheet' type='text/css'
media='paper' href='/paperStyle.css'>", RootPanel.get('myId'));
* Print.it("<style type='text/css'
media='paper'> .newPage {
page-break-after: always; } </style>",
*
"Hi<p class='newPage'></p>By");
* </pre>
*/
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.UIObject;
public class Print {
public static native void it() /*-{
$wnd.print();
}-*/;
public static native void it(String html) /*-{
var frame = $doc.getElementById('__printingFrame');
if (!frame) {
$wnd.alert("Error: Can't find printing frame.");
return;
}
frame = frame.contentWindow;
var doc = frame.document;
doc.open();
doc.write(html);
doc.close();
frame.focus();
frame.print();
}-*/;
public static void it(UIObject obj) {
it("", obj.getElement().toString());
}
public static void it(Element element) {
it("", element.toString());
}
public static void it(String style, String it) {
it("<html><header>"+style+"</header><body>"+it+"</body></
html>");
}
public static void it(String style, UIObject obj) {
it(style, obj.getElement().toString());
}
public static void it(String style, Element element) {
it(style, element.toString());
}
}
HTH
Dominik
On 23 Mrz., 18:34, "jadiaz" <jadi...@gmail.com> wrote:
> Hi Dominik
>
> When Iprint, normally it prints the message This script is part of
> module com.example.example1 sometimes it prints of correct form.
>
> I have tried toprint5 times, 3 times it printed the message, other
> Buttonprint= new Button("Print");
> > > When Iprinta object with styles, the result is the message:
I'm using the corrected Print class from Andre Feller too.
On 26 mar, 08:58, "Dominik Steiner" <Dominik.Stei...@partner.bmw-
motorsport.com> wrote:
> Hi jadiaz,
>
> I just tested your code, and it works fine for me here.
>
> I'm using the correctedPrintclass from Andre Feller.
>
> /**
> * <pre>
> * Generic printing class
> * can be used toprintthe Window it self, DOM.Elements, UIObjects
> > > - Mostrar texto de la cita -- Ocultar texto de la cita -
We are experiencing the same strange issue.
The print script seems to select the wrong iframe in some
circumstances.
The text 'This script is part of module xyz ' is contained in a
standard GWT invisible iframe.
Some observations:
- This problems seems to appear only in IE, not in FireFox.
- It happens only for 'complex' contents (relatively large HTML) but
not for 'simple', small text content.
Luc
just apply a style to your widget and then call window.print... it
will be formatted by css easy easy... including printing more than one
page :)
I try in IE 6.0 and it printed wrong, it printed correctly sometime.
Also I try in IE 7.0 and it printed the message and it printed without
styles, but never correctly.
Thank you!!!
On 27 mar, 15:20, "Andre Freller" <andre.frel...@gmail.com> wrote:
> I downloaded Jose code and tested on both IE and FF and it worked!
> Luc if you have an example that doesn't work please send it to me in pvt so
> I can examine. Also please inform the IE version you are experiencing.
> problems.
>
> Regards,
> Freller
>
> On 3/27/07, Luc Claes <luc.cl...@gmail.com> wrote:
>
>
>
>
>
> > The print script seems to select the wrong iframe in some
> > circumstances.
> > The text 'This script is part of module xyz ' is contained in a
> > standard GWT invisible iframe.- Ocultar texto de la cita -
this is my code:
Stampa= new Button("Stampa");
Stampa.addClickListener(new ClickListener(){
public void onClick(Widget arg0) {
Print.it("<link rel='StyleSheet' type='text/css'
href='widgets.css'>",tableA);
}
});
where tableA is asortable-rocket,with this css:
.rocket-sortableTable {
background-color: white;
}
.rocket-zebraFlexTable-oddRow {
background-color: #CCCCFF;
color: #330000;
}
.rocket-zebraFlexTable-evenRow {
background-color: #FFCCFF;
color: #330000;
}
.rocket-sortableTable-columnHeader {
font-weight: bold;
text-transform: uppercase;
background-color: white;
color: FFFFFF;
}
.rocket-sortableTable-columnHeader-sortable {
cursor: pointer;
}
.rocket-sortableTable-columnHeader-sorted {
cursor: default;
font-weight: bold;
color: #ff0000;
background-color: #bbbbff;
text-transform: uppercase;
}
.rocket-sortableTable-sortedColumn {
cursor: default;
}
.rocket-sortableTable-sortDirectionArrows {
cursor: pointer;
}
??????????
-----
On Mar 30, 10:36 am, "jadiaz" <jadi...@gmail.com> wrote:
> Hi Andre!!
>
> I try in IE 6.0 and it printed wrong, it printed correctly sometime.
> Also I try in IE 7.0 and it printed the message and it printed without
> styles, but never correctly.
>
> Thank you!!!
>
> On 27 mar, 15:20, "Andre Freller" <andre.frel...@gmail.com> wrote:
>
> > I downloaded Jose code and tested on both IE and FF and it worked!
> > Luc if you have an example that doesn't work please send it to me in pvt so
> > I can examine. Also please inform the IE version you are experiencing.
> > problems.
>
> > Regards,
> > Freller
>
> > On 3/27/07, Luc Claes <luc.cl...@gmail.com> wrote:
>
> > > Theprintscript seems to select the wrong iframe in some
The text 'This script is part of module xyz ' is contained in a
nocache.html, but I don't know because it's print this page.
I change this:
public static native void it(String html) /*-{
var frame = $doc.getElementById('__printingFrame');
if (!frame) {
$wnd.alert("Error: Can't find printing frame.");
return;
}
frame = frame.contentWindow;
var doc = frame.document;
doc.open();
doc.writeln(html);
question = confirm("Print document?");
doc.close();
frame.focus();
if (question != "0")
frame.print();
}-*/;
if show message always it works fine.
bye
On 3 abr, 14:43, "Andre Freller" <andre.frel...@gmail.com> wrote:
> Guys,
>
> If you have an example of this miss behaviour, please send it to me in PVT
> in a ZIP file.
>
> Regards,
> Freller
>
> On 4/3/07, ak.agonia <sergio.brigug...@gmail.com> wrote:
>
>
>
>
>
> > why,when i try to print,the result is a white page,with only header of
> > page??- Ocultar texto de la cita -
/**
* <pre>
* Generic printing class
* can be used to print the Window it self, DOM.Elements, UIObjects (Widgets) and plain HTML
*
* Usage:
* You must insert this iframe in your host page:
* <iframe id="__printingFrame" style="width:0;height:0;border:0"></iframe>
*
* Window:
* Print.it();
*
* Objects/HTML:
*
Print.it(RootPanel.get("myId"));
* Print.it(DOM.getElementById("myId"));
* Print.it("Just <b>Print.it()</b>!");
*
* Objects/HTML using styles:
* Print.it("<link rel='StyleSheet' type='text/css' media='paper' href='/paperStyle.css'>", RootPanel.get('myId'));
* Print.it("<style type='text/css' media='paper'> .newPage { page-break-after: always; } </style>",
* "Hi<p class='newPage'></p>By");
* </pre>
*/
package br.com.freller.tool.client;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.UIObject
;
public class Print {
public static native void it() /*-{
$wnd.print();
}-*/;
public static native void buildFrame(String html) /*-{
var frame = $doc.getElementById('__printingFrame');
if (!frame) {
$wnd.alert("Error: Can't find printing frame.");
return;
}
var doc = frame.contentWindow.document;
doc.open();
doc.write(html);
doc.close();
}-*/;
public static native void printFrame() /*-{
var frame = $doc.getElementById('__printingFrame');
frame = frame.contentWindow;
frame.focus();
frame.print();
}-*/;
public static class PrintFrame implements Command {
public void execute() {
printFrame();
}
}
public static PrintFrame printFrameCommmand = new PrintFrame();
public static void it(String html) {
try {
buildFrame(html);
DeferredCommand.add(printFrameCommmand);
} catch (Throwable exc) {
Window.alert(exc.getMessage
());
}
}
public static void it(UIObject obj) {
it("", obj.getElement().toString());
}
public static void it(Element element) {
it("", element.toString());
}
public static void it(String style, String it) {
it("<html><head>"+style+"</head>\n<body>"+it+"</body></html>");
}
public static void it(String style, UIObject obj) {
it(style, obj.getElement().toString());
}
public static void it(String style, Element element) {
it(style, element.toString());
}
} // end of class Print