JSF Mini Book – Tips, concepts and good practices

Hiding the comments of the xhtml page

Sometimes when developers go to a website they search through the generated code of the page. Sometimes it is possible to see comments that a developer left in the page. For example, if you access the site http://uaihebert.com you may find comments like: “<!– Google Analytics Tracking by Google Analyticator 6.2: http://ronaldheft.com/code/analyticator/ –>”, “<!– ending category –>”, “<!– close expanded month –>”, etc.

With JSF there is an option to hide this kind of comment from the user, the comments will not be sent to the user page. To see this configuration in action add the following code in the “index.xhtml” page:

<!-- Testing -->

Start the server and access the page; check the source code of the page and you will see the commented code there.

To hide the comments found in page add the code below in the web.xml file and the comment will be hidden from the user:

<context-param>
	<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
	<param-value>true</param-value>
</context-param>

18 thoughts on “JSF Mini Book – Tips, concepts and good practices

  1. Really cool material! I agree with Tim. If this could be distributed in pdf format, you will become a little more famous. :) Thanks, good job!

  2. I’m not able to see this library applied in my program.
    Output is: Real Madrid, Champion!!! (No image and style)

    Please let me know what I’m missing.

  3. I was trying to learn Spring MVC for last 2 months, Every time i try to start, i get stuck somewhere. 2 Months passed, and i did not learn anything. I purchased two books for spring. Finally i quit Java web programming. One day I thought to give a try to JSF. and found some tutorials online, worked on them and I loved it. Your tutorials are going to help me a lot.
    Thank you so much.
    I would like to tell people here, don’t go near spring, It’s a piece of crap.

    • Arslan,

      Thanks for the feedback.

      My next post will be a full web application with Spring MVC.

      Maybe this application will help you understanding better the Spring, it is a good tool! =D

      See you later.

  4. With your code lines

    and

    eclipse was giving error that:

    Multiple annotations found at this line:
    – Invalid location of text (“) in tag ().
    – Invalid location of text (=”) in tag ().
    – Element type “h:outputStylesheetlibrary” must be followed by either attribute specifications, “>”
    or “/>”.

    So I’ve corrected it by changing lines to

    But I think as you mentioned in case of versions of resources, it will automatically picks up latest version. but the code I’m using will not control the version. It looks like hard-coded.

    What you say about it?

    Moreover, You wrote:
    “To use a mapped library by the ResourceHandler let us create a folder named “index.xhtml” inside the folder “/WebContent”.”

    I think you have not created a folder name “index.xhtml” but you have created a file named “index.xhtml”. If I’m right then you need to correct it. :)

    • Hello Arslan, how are you?

      Unfortunately the xml are not displayed here. =/

      Could you send me an email with the code and the texts that you wrote?

      Thanks for your support and passing by.

      My email is contato (at] uaihebert (d0T) com

      Thanks

Leave a Comment