| | 1339 | |
| | 1340 | void example_Notification(final Window main, String param) { |
| | 1341 | final Window sub1 = new Window(""); |
| | 1342 | main.addWindow(sub1); |
| | 1343 | |
| | 1344 | sub1.showNotification("The default notification"); |
| | 1345 | |
| | 1346 | //Notification notif = new Notification("Title"); |
| | 1347 | } |
| | 1348 | |
| | 1349 | void example_Print(final Window main, String param) { |
| | 1350 | if (param != null && param.equals("simple")) { |
| | 1351 | main.addComponent(new Label("<input type='button' onClick='print()' value='Click to Print'/>", Label.CONTENT_XHTML)); |
| | 1352 | return; |
| | 1353 | } |
| | 1354 | |
| | 1355 | // A button to open the printer-friendly page. |
| | 1356 | Button printButton = new Button("Click to Print"); |
| | 1357 | main.addComponent(printButton); |
| | 1358 | printButton.addListener(new Button.ClickListener() { |
| | 1359 | public void buttonClick(ClickEvent event) { |
| | 1360 | // Create a window that contains stuff you want to print. |
| | 1361 | Window printWindow = new Window("Window to Print"); |
| | 1362 | |
| | 1363 | // Have some content to print. |
| | 1364 | printWindow.addComponent(new Label("Here's some dynamic content.")); |
| | 1365 | |
| | 1366 | // To execute the print() JavaScript, we need to run it |
| | 1367 | // from a custom layout. |
| | 1368 | CustomLayout scriptLayout = new CustomLayout("printpage"); |
| | 1369 | printWindow.addComponent (scriptLayout); |
| | 1370 | |
| | 1371 | // Add the printing window as an application-level window. |
| | 1372 | main.getApplication().addWindow(printWindow); |
| | 1373 | |
| | 1374 | // Open the printing window as a new browser window |
| | 1375 | main.open(new ExternalResource(printWindow.getURL()), "_new"); |
| | 1376 | } |
| | 1377 | }); |
| | 1378 | |
| | 1379 | //main.addComponent(new Label("<p>Print this!</p>\n<script type='text/javascript'>print();</script>", Label.CONTENT_XHTML)); |
| | 1380 | } |