I have a problem with GWT method Window.Open. It works normally when I want to open one window. But, when I need to open two or more URL's in a new window, it opens only one. And in a new window always shows last url in list.
for (RoomReservation reservetion : roomReservationListModel.getRoomReservationsList()) {
Window.open(reservetion.getPrintoutUrl(), L10n.getMessages().print(), HtmlCssElementNames.BLANK);
}
Second param without white spaces.
The second argument to Window.open is window's name, not its title (that one is given by the document showing inside). It's used as the target="" for links and forms, among other things, and uniquely identifies the window (or frame or iframe).
You're using the same value each time, so you're reusing the same window for all the URLs.
Use _blank as the second argument to make sure you always open a new window, without the risk to reuse an existing one.
Related
In Lazarus, there are 2 different kinds of tab elements (cf. Free Pascal docs):
TPageControl
TPageControl is a multi-page component that provides a container to hold a variety of controls per page.
TTabControl
It is a tabbed container component which looks identical to a TPageControl. However, there is a fundamental difference because the control always shows the same page whichever tab is selected. In fact, it containts only a single page. The idea behind this concept is illustrated best by an editor or viewer for text files: When the TabControl contains a TMemo then the individual tabs refer to the files loaded into the memo; whenever the active tab changes another file is loaded into the (same) memo.
In this sense, JavaFX TabPanes are quite similar to TPageControls, but I rather want to replicate a TTabControl. I know I could in fact programmatically create a new Tab(), but I want to visually design it in SceneBuilder.
Is there maybe a way to load a separate .fxml file into a new Tab() element which is then added to the TabPane? (And how could I then access a tab's children?)
I chose the easiest approach: Implementing a head-less TabPane to detect when the user switches between tabs. The elements that appear to the user as the “tab content” are actually placed outside the TabPane, and their content is dynamically changed whenever the tab is switched.
I know that I can use EXTRA_APPLICATION_ID so as not to make chrome always open a new tab, but this has an undesired effect: it will open the URL in the last used tab, which I don't want to.
My intention is this: open the URL in a new tab only for the first time and then always use that tab, independently of whether the user has been navigating to other tabs.
Why I want this: Because I'm getting the copied to clipboard text and I want that text to be searched at a specific URL. So if the user is in some news website and copied a word he wants to be searched for, chrome will be opened at the same tab he was, which is undesired.
Is there a way to achieve this?
there's no way to do that (because never getting the index of the opened tab returned - and not being able to tell which tab one wants to remote; this does not work alike a Chrome extension).
but you could instead just use a WebView - which would provide the desired effect - despite never leaving the app; or even a WebView in an overlaid DialogFragment, instead of a new Activity.
I'm writing a test when you get all the links from the website and click them. But I need to click some links that in the beginning are hidden or some links that appear only in other pages. Till now, I'm only got to the point that test gets all the active links from homepage and clicks them. I'm new to Selenium webdriver and java, so can you suggest how should I write the test that checks for new appearing links after clicking one or something similar?
I usually write my Selenium tests much more specifically, but were I to attempt this I suspect I would start by making use of findElements(By.tagName("a")) to get all currently available anchors, probably put them into a data object which included if that anchor as been clicked yet and put those data objects into a Set. Map that Set to the currentUrl to keep track of what links were found on what pages. After a click (and recording that you clicked that anchor in its data object) you could check the currentUrl (without any #s) with the last one (without any #s) to determine if that click loaded a new page. If the urls match, I would call findElements again and add those to the existing Set. If they don't match repeat the process for the new currentUrl. Some additional things to be aware of would be handling new Windows and frames, which would require a switchTo and iterating through all the frames (and nested frames).
I want to get and set the position within a SWT browser but I don't know how.
First, I created a browser control:
Browser browser = new Browser(shell, SWT.NONE);
Then I launched a HTML document:
File file = new File("C:\\test\\index.html");
browser.setUrl(file.toURI().toString());
That works perfect so far.
Now I scroll down the page to find an interesting text passage and click a menu item to create a kind of bookmark.
My question is: How can I get the current focus position (x,y) to remember the point in the text and how can I reset the position later to "apply" a specific bookmark?
You can interact with the browser content through Browser#evaluate() and Browser#execute().
Both methods allow to execute Javascript in the context of the browsers document.
To send Javascript code that queries the current position, use something like:
Object position = browser.evaluate( "window.getCurrentPosition();" );
The type of the return value depends on the code that is evaluated. Debug through the code to see what the actual return type is.
If you aren't interested in the return value, use execute. For example to set the current position you would use:
browser.evaluate( "window.setCurrentPosition( x, y );" );
Please note that the Javascript is pseudo-code and doesn't actually return the current position.
If you run into SWTExceptions, it is likely that the document isn't fully loaded yet and you need to delay the execution of the Javascript code until it is fully loaded as explained here:
https://stackoverflow.com/a/7802717/2986905
I'm viewing HTML in an SWT Browser widget. I am appending logging messages to the end of the content and would like to keep the bottom visible all the time. Currently, whenever I append text to the content, I first set the new text:
browser.setText(content);
And then I scroll down the Browser widget via JavaScript:
browser.execute("window.scrollTo(0,100000);");
The problem with this is that when I set the text, the widget switches to the top again before scrolling down, so when I append lots of messages quickly, the browser widget is showing the top part most of the time, occasionally flickering when switching to the bottom. This makes it impossible to follow what is being logged at the bottom.
I am aware that I could use a tree viewer and get all the convenience of the Eclipse platform, but there is a Swing version of the app too and both should use the same HTML with CSS presentation.
Ideally I'd like to avoid embedding a Swing component, but if there is one that would allow this, I'd be happy to hear about it. I have tried it with a JEditorPane inside a JScrollPane, appending to the content via the editor kit's read method:
editorPane.getEditorKit().read(/*...*/);
And then scrolling down like this:
editorPane.setCaretPosition(editorPane.getDocument().getLength());
This works very smoothly for the standalone Swing app, but embedded in Eclipse it flickers and does not keep up with fast updates of the HTML content.
Right now the only way I can make this work smoothly inside Eclipse is prepending to the Browser widget's content instead of appending, but I'd really prefer adding new messages at the bottom, not at the top.
Rewriting the whole HTML content every time seems unnecessarily busy-work, and there may not be a way to prevent some browsers from scrolling to the top each time you redraw the entire page. Especially if you allow the logs you show to get very long, this will get slower and slower as the log gets longer.
A better solution might be to use JavaScript to append to the page. You're already using
browser.execute()
How about something like this (assuming "itemID" is the ID of the DIV containing the content):
String newContent = newContent.replaceAll("\n", "<br>").replaceAll("'", "\\\\'");
browser.execute("document.getElementById(\"itemID\").innerHTML += '"
newContent + "'");
You have to do the replaceAll() and you may need a couple more transformations, depending on your log content. I've noticed that browser.execute() doesn't like it if the script contains newlines, for example, and single quotes in your string needed to be quoted as I show above.
I would have just added this as a comment, but it wouldn't let me (not enough reputation). You can ship XUL in a nonstandard location on the mac, by setting a system property.
System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "/fubar/xul/Versions/1.9.0.7/");