Programatically set productionMode?

In Vaadin 7, can you programatically set productionMode as opposed to specifying it in the web.xml?

If not, what deployment techniques do you suggest whereby it’s in debug mode when developing locally, but set to production mode in the war file built for deployment to the server?

Thanks,

Jonathan

Have look at
https://vaadin.com/forum/#!/thread/1147433

Thanks. I had seen that but it seemed specific to Vaadin 6. However, took another look and applied the same idea to Vaadin 7. VaadinServlet works a bit differently than Vaadin 6 ApplicationServlet, but not that differently. The new custom servlet to use is:

[code]
import com.vaadin.server.DefaultDeploymentConfiguration;
import com.vaadin.server.DeploymentConfiguration;
import com.vaadin.server.VaadinServlet;

import java.util.Properties;

public class CustomServlet extends VaadinServlet {

@Override
protected DeploymentConfiguration createDeploymentConfiguration(
        Properties initParameters) {
    if (some condition) {
        initParameters.setProperty("productionMode", "false");
    } else {
        initParameters.setProperty("productionMode", "true");
    }
    return new DefaultDeploymentConfiguration(getClass(), initParameters);
}

}
[/code]The “some condition” above is just pseudo code, to be filled in with whatever the condition happens to be. In my dev environment I use VM option -Dproject.debug.mode=true and then check

String prop = System.getProperty("project.debug.mode"); boolean b = (null != prop && prop.equals("true")); In web.xml you have to point to this new servlet so instead of

<servlet-class>com.vaadin.server.VaadinServlet</servlet-class> use:

<servlet-class>your new custom servlet</servlet-class>

Just what I needed, thanks for posting the code!