How to redirect another page when click menuitem

How to redirect another page when click menuitem

Hi,

You can perform custom actions instead of opening application windows if you register custom screen in web-screens.xml.

  1. Create a Java class that implements Runnable and opens web page using WindowManager:

import com.haulmont.cuba.web.App;
import com.haulmont.cuba.web.WebWindowManager;

public class OpenExternalWebPage implements Runnable {
    @Override
    public void run() {
        WebWindowManager wm = App.getInstance().getWindowManager();
        wm.showWebPage("http://google.com", null);
    }
}
  1. Register this class in web-screens.xml using IDE:

<?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="externalWebPage"
            class="com.company.demo.web.OpenExternalWebPage"></screen>
</screen-config>
  1. Create a menu item in Studio with id of the registered screen

In version 6.5 you will be able to set class or bean/beanMethod directly to menu item from Studio.