I just tried to setup my jsf project with bootstrap. Everything works fine except that when I added a bootstrap template that includes the "role
" attribute. I get a message that says Attribute role is not allowed here
I'm not good with design and I'm focusing more with the backend so I really need to use bootstrap.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition>
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="..." alt="..."/>
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>
</div>
</ui:composition>
</html>
我无法弄清楚为什么在识别出所有其他标签和属性时它不会读取该属性。
任何可能的解决方案?
谢谢。
答案 0 :(得分:2)
你的doctype错了。 role
属性是HTML5(ARIA)的一部分,而不是XHTML 1.0。
相应地修复doctype。
<!DOCTYPE html>
您的编辑器(IDE)只是根据doctype验证文档。这不是JSF也不是Bootstrap特定的问题。这与基本HTML有关。
顺便说一句,在Facelets组合中,您实际上并不需要XML prolog或doctype。无论如何,Facelets将忽略这些。下面的内容应该完整:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
<!-- Content here -->
</ui:composition>