eclipsetomcatjsf-2facelets

Changes in .xhtml file not reflected in browser, restart and build needed


If I make changes in my .xhtml file, the changes are not getting reflected on the screen in my browser. To get it to work, I have to restart the server everytime. This seems unwieldy to me.

I have added the following context parameters in my web.xml:

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
</context-param>

However, they did not have any effect.

My technology stack is listed below:


Solution

  • If you're using an IDE, then you have to configure your IDE as well to publish changes to the server immediately. Otherwise the webapp which is running on the server won't get any notion of those changes.

    As you're using STS which in turn is basically Eclipse for Java EE which is preloaded with a bunch of Spring specific plugins, I think that giving a generic Eclipse-targeted answer is more than sufficient.

    In Eclipse, you just have to doubleclick the server entry in Servers view and then edit the Publishing section to set Automatically publish when resources changes and set the publishing interval as low as possible. It can even be 0 seconds.


    enter image description here


    That javax.faces.FACELETS_REFRESH_PERIOD only applies on the files in the webapp context. You just have to make sure that the IDE is publishing changes to the webapp context as soon as possible.