open External link in OS default browser from xpinc - xpages

I have following requirements. I am using Notes 853/ IBM 9.
Open External link using System default browser when click anchor tag from xpinc
Currently its open external url also with XUL runner even though i have set the following properties.
File -> Preference - > Web browser -> Use the browser I have set as the default for the operating system.
Please advice if have any work around for this issue.
Along with i have one more issue. If external link is https, then xpinc not allow to open in new tab. I mean taget = "_blank" is not works. It only work with "self"

Most likely you won't like the answer you are about to read:
XPiNC runs inside a browser (the embedded XULRunner a.k.a Firefox, the elder). So you could rephrase the question: How do I open a link in one browser from another browser (e.g. Open a link in Chrome from Firefox or from Opera in IE)?
The answer is: you can't (at least for the moment)

I had the same question, and I found the answer at this site: https://caysal.wordpress.com/2016/04/22/xpinc-open-url-link-in-os-default-browser/
In case this site goes down, the solution (provided by Chris Toohey) was the create a Java Bean which reads thus:
package com.dominoguru.xulHack;
public class xulPunter {
public static void punt(String url) {
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
and then to call this within your SSJS as:
<xp:this.action>
<![CDATA[#{javascript:
importPackage(com.dominoguru.xulHack);
xulPunter.punt("http://www.google.com");}]]>
</xp:this.action>
Although this question is almost 5 years old, I had a similar issue and hope this will help anyone who has the same issue in the future.

Related

Adding tree nodes to an Xpages Extension Library Accordion Control

I'm trying to add nodes dynamically to an Extension Library Accordion control. The whole idea is to build a menu with its options being brought from a view (view entries). I started with a very basic logic which I got from here (thanks to this guy Kraeven X BTW). I declared a variable of type accordion, and then created a new instance of BasicContainerNode, and BasicLeafNode. Everything worked fine, I was able to add the the BasicLeafNode as a child of the BasicContainerNode and set the labels for both.
The problem started when I tried to add the newly created node (and its child) to my accordion control using the addNode(ITreeNode node) method.
The page crashes with an Error 500 (HTTP Web Server: Command Not Handled Exception).
Any Ideas why the addNode(ITreeNode node) method ain't working?? What am I doing wrong???
Here's the SSJS code in my afterPageLoad:
try{
var newContainer:com.ibm.xsp.extlib.tree.impl.BasicContainerTreeNode = new com.ibm.xsp.extlib.tree.impl.BasicContainerTreeNode();
newContainer.setLabel("Dynamic Container Node");
var newNode:com.ibm.xsp.extlib.tree.impl.BasicLeafTreeNode = new com.ibm.xsp.extlib.tree.impl.BasicLeafTreeNode();
newNode.setHref("http://www.google.com");
newNode.setLabel("Dynamic Basic Node");
newContainer.addChild(newNode);
var acc = getComponent("accordion1");
acc.addNode(newContainer);
}catch(e){
print(e.toString);
}
Thanks in advance for any help.
:)
Your code works well.
Look for some other issue on your XPage. Activate "Display XPage runtime error page" or look at the log file on server to find out what causes the error.

XPages Style Class does not work on Label in browser but appears in Designer

This has been eating at me for a while now. I seem to run into the issue sometimes -- I have a label that has a style class from a stylesheet that I can see working correctly in Domino Designer:
However, when it appears on the web, there in no styling:
I have performed a Clean which I thought might correct this issue.
Here is the code:
<xp:label value="Email Address is already in use." id="emailExistsText"
styleClass="myCustomErrorMessage">
<xp:this.rendered><![CDATA[#{javascript:var emailCheck = sessionScope.get("emailExists");
if (emailCheck == "true") {
return true;
}
else {
return false;
}}]]>
</xp:this.rendered>
Is it because there is a hide/when script on the label?
Thanks!
Some other CSS class must be overriding your custom CSS class. Check with for instance Chrome Developer Tools or Firebug what CSS classes and properties affect the style on your label.
Using Chrome Developer Tools or Firebug is essential in "debugging" styling issues.
What fixed this -- having the style class appear correctly -- was clicking the "refresh" icon/button in the address bar of Firefox. That was really interesting that it corrected the issue.
After performing a Clean, removing all cached files, restarting the machine, it was clicking the refresh button that fixed it.

Adapting Modal Dialog Script to Firefox

I'm adapting my regression tests to test a web app in firefox. The biggest stumbling block seems to be how to automate the modal dialogs in firefox.
In ie I use variations of the script below, but it doesn't work in Firefox. Is there an alternative that will work in both ie and firefox?
popup=Thread.new {
autoit=WIN32OLE.new('AutoItX3.Control')
ret=autoit.WinWait(title,"",60)
if (ret==1)
puts "There is popup."
autoit.WinActivate(title)
button.downcase!
if button.eql?("ok") || button.eql?("yes") || button.eql?("continue")
autoit.Send("{Enter}")
else
autoit.Send("{tab}")
autoit.Send("{Enter}")
end
elsif (ret==0)
puts "No popup, please check your code."
end
}
at_exit { Thread.kill(popup) }
end
button.click_no_wait
check_for_popups("Message from webpage", "OK")
Given you are talking about a javascript created dialog, I really have to ask, is there a lot of value in actually testing those?
It basically amounts to testing the functionality of the browser
If you are talking about the type of popups described here http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups then I think the first solution, of overriding the javascript may well be your best cross platform option.
The problem with modal dialogs like this is that they are basically a UI even that is happening out at the OS level, it's no longer inside the browser DOM, and thus you need tools that are specific to the OS (like stuff that depends on win32ole, such as autoit) in order to generate the necessary interaction with the native UI and click buttons, send keystrokes etc. Most of the solutions presented should I think work with FF on windows (with proper renaming of expected window titles etc) but would fail on a mac or *nix OS. That means you need a different solution for each OS, which is a pain.
It might simply be easier to verify you can find the proper stuff that would fire the event in the HTML of the page, so you know an event WOULD be fired, and then override things so it isn't. After all it's not really your job to validate that the browser pops up a local dialog when something like alert('This is an alert box') is invoked in javascript. Your concern is that in the HTML a given element is coded to fire off the event that is needed e.g. that there's something like this onClick = 'javascript:x = confirm('Do you really want to do this');" affiliated with the element
I am experiencing a similar problem in Firefox (and I do have to test in Firefox). I can see the code calling the Javascript but when I try to override as described above nothing happens. Is there any kind of a workaround for this? Anticipated updates to Watir? ;-)

Eclipse RCP: How to configure the Perspective Menu?

I need to have total control of the perspective menu.
I already hacked into the platform to disable the CONTEXT menu:
private void disablePerspectiveToolbarMenu() {
PerspectiveBarManager perspectiveBarManager =
((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar();
if (perspectiveBarManager!=null){
ToolBar toolBar = perspectiveBarManager.getControl();
Listener[] listeners = toolBar.getListeners(SWT.MenuDetect);
if (listeners != null){
for (Listener listener : listeners){
toolBar.removeListener(SWT.MenuDetect, listener);
}
}
}
}
But i need also to control the default contents of the PERSPECTIVE MENU. There is one option that is always present that gives access to a Perspective List Shell. I need to remove that option from the menu.
It's a shame that the perspective menu is totally out of user control. I just need to have the perspectives added to the menu, and nothing more!
Thanks.
There are 3 potential options to get rid of Other:
Set the
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU
preference to false in your RCP app. This can be done by including a plugin_customization.ini file with your product definition.
Patch the workbench in your RCP app.
Have a look at
org.eclipse.ui.internal.PerspectiveBarNewContributionItem
and
org.eclipse.ui.actions.ContributionItemFactory.PERSPECTIVES_SHORTLIST
Don't include the default
perspective bar in your RCP app.
Instead, create a perspective bar
using org.eclipse.ui.menus, a
toolbar, and the openPerspective
command.
I did some research and the solution did not work as I expected it. Finally I found my mistake.
To set the property in the plugin_customization.ini I tried:
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU=false
but this is not the correct notation!!! Please see the correct solution I added finally to the plugin_customization.xml
org.eclipse.ui/SHOW_OTHER_IN_PERSPECTIVE_MENU=false
So the name of the interface or the class specifying the property ist not part of the notation!

How to control application from WebBrowser Control?

I've googled it, but came out empty. And the worst thing is that I know it is possible.
Anyway, I'm developing an application that uses the WebBrowser control to display information regarding an object (like Outlook does with the Rules and Alerts dialog box).
My question is how do I do for the click on a, say, hyperlink in the WebBrowser execute some function within the Windows Form?
For instance, say I have a link like this and when I click it I want the application to display an specific form, like the Outlook does when you click on hyperlinks like People and Distribution List
This looks useful: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code
ChrisW's answer will work, but there's another way if you're just relying on hyperlinks.
In Comicster, I have links in my WebBrowser control like this:
New Collection
And then in the WebBrowser's Navigating event, I have some code to check if the user has tried to navigate to an "action:" link, and intercept it:
private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
if (e.Url.Scheme == "action")
{
e.Cancel = true;
string actionName = e.Url.LocalPath;
// do stuff when actionName == "FileNew" etc
}
}
With a little bit of code you can even parse the URL parameters and "pass them through" to your host application's action, so I can do things like:
Edit this issue
... which will open a properties dialog for the issue with ID 1.

Resources