I want to open link in another web view control on clicking the hyperlinks in another web
view in swing using Java FX
Actually i am having two web view controls A n B on the same screen .
On clicking the hyperlink in a , new link should be opened in B web
view control
Allow webviewA to open content in webviewB
Use setCreatePopupHandler:
webviewA.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
#Override public WebEngine call(PopupFeatures popupFeatures) {
return webviewB.getEngine();
}
});
Or, if you are using jdk8 and don't like typing:
webviewA.getEngine().setCreatePopupHandler(
popupFeatures -> webviewB.getEngine()
);
Make your html links open content in a new window
Define the hyperlinks in the document loaded in webviewA using target="_blank"
For example:
webviewA.loadContent(
"<a href='http://sundae.triumf.ca/pub2/cave/node001.html' target='_blank'>" +
"XYZZY" +
"</a>"
);
when you click on the hyperlink and utter the magic word, it will open the Colossal Cave adventure in webviewB.
Related
I am using Java and Vaadin to create a simple view where an image is displayed. I have a single Image element containing a source link. Here is my code.
#Route(value = "")
public class MainView extends VerticalLayout {
public MainView() {
add(new Image("https://media.reaperscans.com/file/4SRBHm/comics/14659ab2-5650-4aaf-a5bb-9ad5a9828662/chapters/3aff6399-5ff4-46d1-b502-88788510d962/000.jpg", ""));
}
}
This compiles to a HTML in the browser containing an image element:
<img src="https://media.reaperscans.com/file/4SRBHm/comics/14659ab2-5650-4aaf-a5bb-9ad5a9828662/chapters/3aff6399-5ff4-46d1-b502-88788510d962/000.jpg">
When I open this image in new tab I can see the image correctly, but when I see it in my app there is only:
EDIT:
I can open the image using the link in Google Chrome.
If you open the image on Chrome you will notice the website doesn't allow hotlinking. That's why it doesn't load. Try using a different image (from Wikipedia, for example) and it should work well.
new Image("https://upload.wikimedia.org/wikipedia/commons/8/8e/Vaadin-flow-bakery.png","vaadin");
I recommend using the alt attribute as well, instead of leaving it empty as you had in your original question.
I have to navigate between my components and I use a custom button like this:
button.addClickListener(click -> {
UI.getCurrent().navigate(ClassToNavigate.class);
});
The url does refresh in the search bar but it only shows a black page, I've to hit F5 to see the component in my parent layout.
My only fix is to add:
UI.getCurrent().getPage().reload();
...which reloads the page after navigating to the URL, and that breaks the UX in my opinion, however... when using a BeforeEnterEvent on a class and using the method:
forwardTo(ClassToNavigate.class);
redirects perfectly... although I can't have BeforeEnterEvent for every menu button I have, I can't see why forwardTo() works perfectly and navigate() doesn't.
Is there a way to navigate without having to reload the page? And without using RouterLink which I can't because I'm already using a custom component.
Thanks in advance!
First of all i would like to say that i have gone through all the posts which are similar to my query but i have some different requirement.
In our project we are using gwt to develop the modules, in one of our module, we have "Edit" button which opens a new browser window which includes 'CKEditor'.
We are modifying the data in ckeditor comes(by url) from gwt widget .
The Window opens by using following code snippet(JSNI) in my gwt widget:
private static native BodyElement getBodyElement(String url) /*-{
var win = window.open("url", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
return win.document.body;
}-*/;
The newly opened window have the html form which is with ckeditor.
So here i am closing new window once my form has been submitted but i want the edited text to be displayed in old window.
How can i achieve this requirement?
If you can use HTML5, it should be quite easy. Use Messaging.
Take a look here:
Cross-document messaging
With the reference of the newly opened window, yu can establish a communication between both windows.
i m developing a web page, where i want to show vertical menu. when any clicks on menu its content should open on same page inside a box, and on clicking next menu new content should open in same place . I m using java ,JSP,JSF, java script.. can any one help me on.....
jQuery(document).ready(function(){
$("#myLink").click(function() {
$(this).fancybox({href : 'temp.jsp'});
});
});
Open ajax content
I have tried this but i need to design lots of jsps.
use primefaces menu, it has all the fancy you need
You could also try RichFaces - rich:dropDownMenu and rich:popupPanel
rich:dropDownMenu - RichFaces Showcase
rich:popupPanel - RichFaces Showcase
My main goal: When i click the link, a new browser window should be opened and displays the content of entire log file. And the window should not have an address bar and navigation buttons (Back, Forward).
Is there any approach to do this in Spring-MVC project?
Here is what i am doing now:
When i click the link, the controller will be called with a parameter logName.
Now the controller have access to get any kind of details of the log file like content, path, etc... I am setting all these details to an object and sending back to JSP.
Here i am not sure how to open a new window and display the content of the log file in that window.
Please suggest me an approach on this!!
It would be very helpful for me if you can share me with some examples...
Spring or JSP have nothing to do with it, the only way to force user's browser to open a link in a new tab is to use client-side Javascript. window.open() allows configuring the popup to hide certain interface elements (see all options in the documentation)
Your code would look something like:
<input type="button" value="Show Log" onclick="showLog(logName)">
function showLog(logName) {
var url = "/path-to-your-controller.html?logName=" + logName;
window.open(url, "LogPage", "toolbar=no,location=no,menubar=no");
}
However, I don't think using a customised browser popup is a good solution; it's been disappearing from the web for a reason. It would be more elegant to fetch raw data using AJAX and display it in a JS popup: it wouldn't interfere with user's page navigation (you tagged the question with jQuery, you could use jQuery UI for that).
What is more, I wouldn't be surprised if window.open wasn't supported by all browsers in the same way† - something to keep in mind if you're targeting a wider audience.
† seems that Chrome ignores location=no, for instance