How do I add a menu item that links to an external url and another menu item that link to an url in the app domain?
Thanks…
How do I add a menu item that links to an external url and another menu item that link to an url in the app domain?
Thanks…
Hi,
Currently, it can be done only from IDE:
public class ExternalUrlDemoRunner implements Runnable {
@Override
public void run() {
App app = App.getInstance();
WebWindowManager wm = app.getWindowManager();
wm.showWebPage("http://google.com", null);
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<screen-config xmlns="http://schemas.haulmont.com/cuba/screens.xsd">
<include file="com/company/demo/screens.xml"></include>
<screen id="external-demo" class="com.company.demo.web.ExternalUrlDemoRunner"></screen>
</screen-config>
Now you can click on your new menu item and it will open additional browser tab with an external URL. Please note that users have to allow pop-up windows on your application domain otherwise they will see a warning in a web browser.
If you want to open some page on application domain you can obtain the application URL using ControllerUtils:
import com.haulmont.cuba.web.controllers.ControllerUtils;
...
String currentAppUrl = ControllerUtils.getLocationWithoutParams();
WOW…Thank you for your help…
CUBA…This is particularly painfully and complex to do such a simple task. Is there no way for the CUBA platform to accomplish this easier???
CUBA was designed to save time in development, but this oversight has given me second thoughts is using this platform to port my application to.
Disappointed !!!
Just a follow up…
I needed a sub-menu of the “Help” menu to actually point to my app helper section (url). How do I do this a a sub-menu item… (Help -> my-url) ? Doe working with the “Help” menu change the way this modification is done?
Thanks
Hi Donavon,
You are right, the API is currently not very nice. We will consider changing it to make such custom operations for the menu actions more friendly.
Regards,
Aleksey
Hi, sorry for the late answer.
You can do this using Studio Menu Designer. Set Insert before parameter for your menu items or sub menus to aboutWindow.
Hi Aleksey,
Are there any news on this?
Adding menu item which link to external url is so complicated.