How not to specify a on all my JSF custom components</a></h1> </div> <div class="grid fw-wrap pb8 mb16 bb bc-black-075"> <div class="grid--cell ws-nowrap mr16 mb8" title="2016-01-12 19:07:53Z"> <span class="fc-light mr2">Asked</span> <time itemprop="dateCreated" datetime="2018-06-08T12:52:39.007" class="fromnow">Jun 08 '18 at 12:52</time> </div> <div class="grid--cell ws-nowrap mr16 mb8"> <span class="fc-light mr2">Active</span> <time class="fromnow" title="2018-06-08T14:07:22.060" datetime="2018-06-08T14:07:22.060">Jun 08 '18 at 14:07</a> </div> <div class="grid--cell ws-nowrap mb8" title="Viewed 604 times"> <span class="fc-light mr2">Viewed</span> 604 times </div> </div> <div id="mainbar" role="main" aria-label="questions and answers"> <div id="question" class="question" data-questionid="50761099" data-ownerid="3817953" data-score="3"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="50761099"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="3">3</div> <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4"> <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg> <div class="js-bookmark-count mt4" data-value="0">0</div> </button> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>Following Oracle (and others) <a class="external-link" href="https://docs.oracle.com/javaee/6/tutorial/doc/giqzr.html" rel="nofollow noreferrer">documentation</a>, I have all my JSF components looking like : </p> <pre><code><!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://xmlns.jcp.org/jsf/composite" > <composite:interface> ... </composite:interface> <composite:implementation> ... </composite:implementation> </html> </code></pre> <p>Of course, it works properly, but SonarCube disagree with this (rule details <a class="external-link" href="https://3layer.com.br/sonar/rules/show/Web:PageWithoutTitleCheck?layout=false" rel="nofollow noreferrer">here</a>):</p> <blockquote> <p>"title" should be present in all pages</p> </blockquote> <p>There are a couple of solutions :</p> <ul> <li>Asking Sonar to ignore these issues,</li> <li>Adding <code><head></code> and <code><title></code> tags,</li> </ul> <p>But these looks like workarounds and I would like to set a permanent solution.</p></div> <div class="mt24 mb12"> <div class="post-taglist grid gs4 gsy fd-column"> <div class="grid ps-relative"> <a href="../../questions/tagged/jsf" class="post-tag js-gps-track" title="show questions tagged 'jsf'" rel="tag">jsf</a> <a href="../../questions/tagged/sonarqube" class="post-tag js-gps-track" title="show questions tagged 'sonarqube'" rel="tag">sonarqube</a> </div> </div> </div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature owner grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 08 '18 at 12:52">asked Jun 08 '18 at 12:52</time> <a href="../../users/3817953/yunandtidus" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3817953.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="yunandtidus" /> </a> <div class="s-user-card--info"> <a href="../../users/3817953/yunandtidus" class="s-user-card--link">yunandtidus</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,847</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="29 silver badges">29</li> <li class="s-award-bling s-award-bling__bronze" title="42 bronze badges">42</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader grid ai-center mb8"> <div class="grid--cell fl1"> <h2 class="mb0" data-answercount="9">1 Answers<span style="display:none;" itemprop="answerCount">1</span></h2> </div> </div> </div> <a name="50762473"></a> <div id="answer-50762473" class="answer accepted-answer" data-answerid="50762473" data-ownerid="157882" data-score="2" itemprop="acceptedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="50762473"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="2">2</div> <div class="js-accepted-answer-indicator grid--cell fc-green-500 py6 mtn8"><div class="ta-center"><svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8z"></path></svg></div></div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>The <code>DOCTYPE</code> and <code>html</code> tags are only mandatory when you author Facelets templates in a visual page designer. The Java EE tutorial's author had probably in mind that this kind of developers would become the largest group of JSF users. However, after all, this turned out to be untrue. In reality, these visual page designers generate terrible and non-semantic source code full of bad HTML/CSS practices, which one had to cleanup afterwards.</p> <p>When you're authoring Facelets templates in a plain text editor (with syntax highlighting, of course), then you don't necessarily need these <code>DOCTYPE</code> and <code>html</code> tags in template compositions and composites. A root element of <code><ui:composition></code> and <code><ui:component></code> already suffices.</p> <p>So, in your specific case, just use:</p> <pre><code><ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:cc="http://xmlns.jcp.org/jsf/composite" > <cc:interface> ... </cc:interface> <cc:implementation> ... </cc:implementation> </ui:component> </code></pre> <p>And then Sonar won't anymore incorrectly interpret it as a "plain" HTML page.</p> <h3>See also:</h3> <ul> <li><a href="../../questions/4792862/how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets">How to include another XHTML in XHTML using JSF 2.0 Facelets?</a></li> <li><a href="../../questions/10504190/is-there-a-way-to-run-a-jsf-page-without-building-the-whole-project">Is there a way to run a JSF page without building the whole project?</a></li> </ul></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="edited Jun 20 '20 at 09:12">edited Jun 20 '20 at 09:12</time> <a href="../../users/-1/community" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/-1.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Community" /> </a> <div class="s-user-card--info"> <a href="../../users/-1/community" class="s-user-card--link">Community</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> </ul> </div> </div> </div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Jun 08 '18 at 14:07">answered Jun 08 '18 at 14:07</time> <a href="../../users/157882/balusc" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/157882.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="BalusC" /> </a> <div class="s-user-card--info"> <a href="../../users/157882/balusc" class="s-user-card--link">BalusC</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,082,665</li> <li class="s-award-bling s-award-bling__gold" title="372 gold badges">372</li> <li class="s-award-bling s-award-bling__silver" title="3,610 silver badges">3,610</li> <li class="s-award-bling s-award-bling__bronze" title="3,555 bronze badges">3,555</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>