0

DevelopmentConfig not hot reload JS

asked 2022-03-04 19:00:45 +0800

manchen gravatar image manchen
151 2

Hi Guys,

I have a zkspringboot project and I enable DevelopmentConfig, and then run the application, but my javascirpt file change have to restart server. I need to F5 refresh to browser, how do i do it?

public class DemoApplication {
public static void main(String[] args) throws Exception {
    SpringApplication.run(DemoApplication.class);
}

@GetMapping("/mvvm")
public String mvvmExample() {
    return "mvvm";
}

@GetMapping("/resources")
public String resourcesExample() {
    return "resources";
}

@GetMapping("/form")
public String formExample() {
    return "form";
}


@GetMapping("/login")
public String login() {
    return "login";
}

@GetMapping("/secure/{page}")
public String secure(@PathVariable String page) {
    return "secure/" + page;
}

}

@PostConstruct
public void initDevelopmentProperties() throws Exception {
    logger.info("**************************************************************");
    logger.info("**** ZK-Springboot-Demo: development configuration active ****");
    logger.info("**************************************************************");

    //disable various caches to avoid server restarts
    Library.setProperty("org.zkoss.zk.ZUML.cache", "false");
    Library.setProperty("org.zkoss.zk.WPD.cache", "false");
    Library.setProperty("org.zkoss.zk.WCS.cache", "false");
    Library.setProperty("org.zkoss.zk.ui.versionInfo.enabled", "true");

    Library.setProperty("org.zkoss.web.classWebResource.cache", "false");
    Library.setProperty("org.zkoss.web.classWebResource.cache.CSS.hours", "-1");
    Library.setProperty("org.zkoss.util.label.cache", "false");
    Library.setProperty("org.zkoss.web.util.re  source.dir", "/json");

    // enable non minified js
    WebApps.getCurrent().getConfiguration().setDebugJS(true);

    Library.setProperty("org.zkoss.web.classWebResource.cache.etag", "true");
    Library.setProperty("org.zkoss.bind.disableMethodCache", "false");

    // enable for debugging MVVM commands and binding (very verbose)
    Library.setProperty("org.zkoss.bind.DebuggerFactory.enable", "false");
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-07 14:01:43 +0800

hawk gravatar image hawk
3048 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2022-03-07 14:14:18 +0800

Do you mean you load a javascript manually like:

<script src="~./js/myjs.js"/>
<script src="/js/myjs.js"/>

If you run with maven springboot:run, after you modify a js, you need to trigger a build to update js from the /src to /target/ folder. Because spring boot built-in tomcat doesn't load js directly from your project source.

If this is your case, then even you don't active dev profile, the steps above still work.

For example, in IntelliJ IDEA, after I modify myjs.js, I need to press Cmd+Shift+F9 or click the menuitem below:

image description

It doesn't really compile js but just copy the js to the /target folder.

link publish delete flag offensive edit

Comments

This solution is very good, he solved my problem. But I will first use the js under the change target for development Because I change a lot and don't want to rebuild all the time

manchen ( 2022-03-07 14:23:48 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2022-03-04 19:00:45 +0800

Seen: 7 times

Last updated: Mar 07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More