hi Andre,
your solution will work, but using CSS @screen/@print meta selectors
really simplifies everything and does not require additional code
(except of JSNI call to window.print()):
full example:
HTML:
<html>
<head>
<title>Wrapper HTML for PrintMeModule</title>
<meta name='gwt:module'
content='com.mycompany.project.PrintMeModule' />
<link type="text/css" rel='stylesheet' href='PrintMeModule.css' />
</head>
<body>
<!-- two types of content: screen and print -->
<!-- print tag -->
<div id="printContent">This will be printed</div>
<!-- cotnent area wont be printed-->
<div id="content"></div>
<script language="javascript"
src="com.mycompany.project.PrintMeModule.nocache.js"></script>
</body>
</html>
CSS:
@media print {
#content {
display: none;
}
}
@media screen {
#printContent {
display: none;
}
}
(NOTE: TWO DECLARATIONS!);
Java:
package com.mycompany.project.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class PrintMeModule implements EntryPoint {
private Button clickMeButton;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get("content");
clickMeButton = new Button();
rootPanel.add(clickMeButton);
clickMeButton.setText("Print me!");
clickMeButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
DeferredCommand.addCommand(new Command() {
/* @Override */
public native void execute()/*-{
window.print();
}-*/;
});
}
});
}
}
What will be printed?
"This will be printed"
(and everythin we add to "printContent" widget at runtime)
regards,
Peter
On Dec 17, 1:53 pm, "Andre Freller" <
andre.frel...@gmail.com> wrote:
> Manjunath,
>
> See my last post on this thread:
>
>
http://groups.google.com.my/group/Google-Web-Toolkit/browse_thread/th...
>
> Regards,
> Freller