tandraschko / quarkus-myfaces

26 stars 6 forks source link

Set faces projectStage based in Quarkus run mod #5

Closed rmpestano closed 5 years ago

rmpestano commented 5 years ago

It would be nice to set javax.faces.FACELETS_REFRESH_PERIOD to 0 when projectStage is Development, this could be done in QuarkusServletContextListener, something like:

@WebListener
public class QuarkusServletContextListener implements ServletContextListener {

    @ConfigProperty(name = "javax.faces.PROJECT_STAGE") //see application.properties
    String projectStage;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        sce.getServletContext().setInitParameter("javax.faces.PROJECT_STAGE", projectStage);
        if(!ProjectStage.Production.name().equals(projectStage)) {
            sce.getServletContext().setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "0");
        }
    }
}

Then in quarkus:dev mode we can change pages without restarting the application.

OBS: Project stage also is not being set based on application.properties so we need to set it in our on StartupListener, like in showcase example, I think it should also be set in QuarkusServletContextListener.

WDYT?

tandraschko commented 5 years ago

I thought thats automatically done by the jsf impl?

rmpestano commented 5 years ago

Yes, the main issue was that the project stage was not being set, so changing my question, shouldn't we set the project stage in QuarkusServletContextListener?

tandraschko commented 5 years ago

yep would you like to provide a PR and also remove the logic from the showcase then?