Question related to an Embedded URL...

Hi all,

I’m having an application with a text field & a button, where I enter a URL in the text field.
When I click on the button, a MODAL window (with a a PRINT button) opens with the contents of the given URL.
User can navigate to the links inside this MODAL window & upon click of the PRINT button, the CURRENT PAGE should be printed.

So my question is, how do I get the latest URL?
I tried
((ExternalResource)embedded.getSource()).getURL()
& it gives me the URL that I INITIALLY typed.

Following is my open URL method.

private void showURLWindow(String url) {
		final Window win = new Window();
		win.setCaption("Online reservation");
		win.setModal(true);
		win.setResizable(false);
		win.setDraggable(false);
		win.setClosable(false);
		win.setHeight("550px");
		win.setWidth("550px");

		final Embedded embedded = new Embedded("", new ExternalResource(url));
		embedded.setType(Embedded.TYPE_BROWSER);
		embedded.setHeight("500px");
		embedded.setWidth("500px");
		win.addComponent(embedded);
		
		Button btnPrint = new Button("Print");
		btnPrint.addListener(new ClickListener() {
            private static final long serialVersionUID = -1918651951017974341L;

			public void buttonClick(ClickEvent event) {
				[color=#C51C1C]
// Write the code for "URL --> Print" here
[/color]
				// System.out.println(((ExternalResource)embedded.getSource()).getURL());
				getWindow().removeWindow(win);	
			}
		});

		win.addComponent(btnPrint);
		getWindow().addWindow(win);
	}

Any help is greatly appreciated.

Thanks in advance.
Asela.

I’m not sure if I understand you here - do you want to print the document whose URL you gave as a parameter to showURLWindow, a page to which the user has navigated inside the iframe inside the Embedded, or the modal subwindow itself (note that it does not have an URL of its own).

I assume the second one - the URL to which the user has gone inside the iframe. This is probably somewhat tricky, as (if I remember correctly) the Embedded component does not communicate URL changes of the embedded iframe back to the server. Therefore, this would require some custom javascript to find the iframe and get its URL on the client side, or subclassing the client side VEmbedded and having a corresponding server side subclass of Embedded that uses it with a ClientWidget annotation. This way, you could also add the print method directly in the subclasses.

Did you solve this somehow? I’d also like this support, so I’m interested in how you proceeded =)

Hi Henri,

Thanks for the prompt reply.
Yes it’s the second one as you correctly assumed & it seems that I have to think of another solution.
Anyways, thanks again.

Regards,
Asela.

Hi Asela and Henri,

I was wondering if you guys can help me with something that Asela did. He has a textfield and a button, and when the user types an URL and click the button, a modal windows opens with the contents of the giving URL. My problem is that I haven’t been able to open that URL content on a TYPE_BROWSER embedded component. I made a post
http://vaadin.com/forum/-/message_boards/message/340121
with my problem but I think that maybe you can help me here. I know is not the same problem that Asela had, but it’s kind of related (I think so) :slight_smile:

I appreciate your help.
Thank you.

Sebastian

Answer:
http://vaadin.com/forum/-/message_boards/message/340121

:slight_smile: