Java Action not being called

I have created a java action that opens up a web address. I have attached the button to my form and connected to a microflow that runs the action to open the address that is passed to it. However the action does not work when i press the button. When i then re deploy the application the website is opened. I am not sure what i have done wrong. I think it maybe how i am calling as the java code obviously works as it opens the site. Here is my code anyways. // This code is generated by the Mendix Business Modeler version 2.4.5. // The following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package cmdb.actions; import com.mendix.systemwideinterfaces.core.UserAction; import; import; import java.awt.Desktop; import; import java.util.logging.Level; import java.util.logging.Logger; /** * Opens the given web address */ public class OpenWebsite extends UserAction<Boolean> { private String UrlAddress; public OpenWebsite(String UrlAddress) { super(); this.UrlAddress = UrlAddress; } @Override public Boolean executeAction() throws Exception { // BEGIN USER CODE if(UrlAddress != null) { java.awt.Desktop myNewBrowserDesktop = java.awt.Desktop.getDesktop(); myNewLocation = new; myNewBrowserDesktop.browse(myNewLocation); } return true; // END USER CODE } /** * Returns a string representation of this action */ @Override public String toString() { return "OpenWebsite"; } // BEGIN EXTRA CODE public void OpenWebAddress(String OpenAddress) throws URISyntaxException, IOException { java.awt.Desktop myNewBrowserDesktop = java.awt.Desktop.getDesktop(); myNewLocation = new; myNewBrowserDesktop.browse(myNewLocation); } // END EXTRA CODE }
1 answers

I think what you're looking for is a javascript that will open a link for you. As Bas noted, using a java action as you proposed will open the link on the server, not on the client. To open things on the client you need something that will run there, thus javascript.

I'd suggest building some kind of mendix theme which incorporates a javascript to open a particular window. The alternative is to wait for 2.5 and use a custom widget.