Javaserver面临h:按钮未显示

时间:2017-05-03 22:35:49

标签: jsf

我在制作项目时遇到了问题。某些h标签不会在视图中显示。

这是视图代码:

<?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:f="http://xmlns.jcp.org/jsf/core"
      >
    <h:head>
        <title>Facelet Title</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
    </h:head>
    <h:body>
        <div id="main">
            <div id="header">
            </div>

            <div id="menu">
                <ul>
                    <li><a href="#">Admin</a></li>
                    <li><a href="#">Home</a></li>
                </ul>
            </div>

            <div id="content">
                <h1>Lijst van opleidingen</h1>                         
                <h:dataTable var="o" value="#{opleidingController.findAll()}" border="0" >
                    <h:column>
                        <f:facet name="header">Code</f:facet>
                        <h:outputText value="#{o.opl_code}"></h:outputText>
                    </h:column>
                    <h:column>
                        <f:facet name="header">Titel</f:facet>
                        <h:outputText value="#{o.opl_titel}"></h:outputText>
                    </h:column>
                    <h:column>
                        <f:facet name="header">Thema</f:facet>
                        <h:outputText value="#{o.opl_thema}"></h:outputText>
                    </h:column>
                    <h:column>
                        <f:facet name="header">Delete</f:facet>
                        <h:graphicImage id="delete" url="images/delete.gif" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">Edit</f:facet>
                        <h:graphicImage id="edit" url="images/edit.gif" />
                    </h:column>
                </h:dataTable>
                <br /><br />
                <h:button value="Nieuwe Opleiding" outcome="add"></h:button>
                <a href ="add.xhtml">Nieuwe opleiding</a> 
            </div>
        </div>
    </h:body>
</html>

我可以看到a标签但不能看到h:按钮。这是我浏览器中的视图图片(数据库仍为空,这就是列表中没有项目的原因。)

Image is found here

这可能是一个众所周知的简单答案,所以我非常乐意学习新事物!

编辑:

我做了BalusC给我的步骤。这固定了另一页我也遇到了问题。但我之前谈到的页面仍然没有解析xhtml。我得到了包含源代码的提示,我将做:

<?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:f="http://xmlns.jcp.org/jsf/core"
      >
    <h:head>
        <title>Facelet Title</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
    </h:head>
    <h:body>
        <h:form>
            <div id="main">
                <div id="header">
                </div>

                <div id="menu">
                    <ul>
                        <li><a href="#">Admin</a></li>
                        <li><a href="#">Home</a></li>
                    </ul>
                </div>

                <div id="content">
                    <h1>Lijst van opleidingen</h1>                         
                    <h:dataTable var="o" value="#{opleidingController.findAll()}" border="0" >
                        <h:column>
                            <f:facet name="header">Code</f:facet>
                            <h:outputText value="#{o.opl_code}"></h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">Titel</f:facet>
                            <h:outputText value="#{o.opl_titel}"></h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">Thema</f:facet>
                            <h:outputText value="#{o.opl_thema}"></h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">Delete</f:facet>
                            <h:graphicImage id="delete" url="images/delete.gif" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">Edit</f:facet>
                            <h:graphicImage id="edit" url="images/edit.gif" />
                        </h:column>
                    </h:dataTable>
                    <br /><br />
                    <h:button value="Nieuwe Opleiding" outcome="add"></h:button>
                    <a href ="add.xhtml">Nieuwe opleiding</a> 
                </div>
            </div>
        </h:form>
    </h:body>
</html>

0 个答案:

没有答案