Smoothing the JSF development
“ui:debug” – A component that helps in the application development with JSF is the “ui:debug”. To activate the ui:debug just add the following code in the page: “<ui:debug />“. With this component it is possible to access the object tree in the development stage. But, how can we access this values? After the page is displayed use the shortcut ctrl + shift + d. Pay attention that in the Internet Explorer, by example, will add the page in the favorites before opening the dialog box. Each browser will have an unique behavior.
“Project Stage” – Every technology has its advantages/disadvantages regarding software code development. There are situations that some code became a burden when a debug is needed.
Silent errors usually happen in the page and we do not find it until we edit the code. When we work with JSP there is a simple technique to find what is wrong with the page; just add a try/catch that wrap all the JSP code. If any exception happens we can print the error message in the console and see what is wrong.
With JSF there are configurations that can help us developing a page or even when the code is running in production environment; in JSF “stages” are applied in the project to define specific configurations.
To configure a specific stage to your application write the code bellow inside the web.xml:
<context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param>
The allowed values until today are: “Development”, “UnitTest”, “SystemTest”, “Production” (default value). Let us talk a little bit more about the Development stage that will bring us more advantages.
When the “Development” stage is set there is no need to add a “h:message” component in the page just to see if any error message will be displayed.
“REFRESH_PERIOD” – When we work with web technology it might happen that after editing an web page source code, this editing will not be displayed in the page. No matter how many times we edit the file the new added code to the edited file will not be displayed in the page.
JSF has a configuration that indicates to the container that it must search for any kind of updates in the pages. In the code below is written how to add this configuration that is measured by seconds:
<context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> <param-value>2</param-value> </context-param>
Add the configuration above in the web.xml and the container will have a scheduled task to check if any file were updated.