1

我正在尝试实现 jsf + primefaces + twitter bootstrap:

<!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://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
>
<h:head>
    <title>IMPORT JSF SET ATTRIBUTES</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="" />
    <meta name="author" content="" />

    <!-- Le styles -->
    <h:outputStylesheet name="css/bootstrap.css" />
    <h:outputStylesheet name="css/bootstrap.min.css" />
    <h:outputStylesheet name="css/override.css" />

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

    <!-- Le fav and touch icons
<link rel="shortcut icon" href="../assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
-->
</h:head>
<h:body>
    <div class="navbar navbar-inverse navbar-static-top">
        <div class="navbar-inner navbar-large">
            <div class="container">
                <a class="brand" href="#">Name</a>
                <ul class="nav">
                    <li><a href="#buy">Link</a></li>
                    <li><a href="#about">Link</a></li>
                </ul>
                <form class="navbar-form pull-left">
                    <div class="input-append offset1">
                        <h:input class="span5" placeholder="put search terms here"
                            type="text" />
                        <button class="btn" type="submit">
                            <i class="icon-search"></i>
                        </button>
                    </div>
                </form>
                <ul class="nav pull-right">
                    <li class="dropdown"><a class="dropdown-toggle"
                        data-toggle="dropdown" href="#"> How to <b class="caret"></b>
                    </a>
                        <ul class="dropdown-menu">
                            <li class="nav-header">Link</li>
                            <li><a href="#">Link 1</a></li>
                            <li><a href="#">Link 2</a></li>
                            <li><a href="#">Link 3</a></li>
                            <li class="divider"></li>
                            <li class="nav-header">Link</li>
                            <li><a href="#">Link 1</a></li>
                            <li><a href="#">Link 2</a></li>
                            <li><a href="#">Link 3</a></li>
                        </ul></li>
                    <li><a href="#login">Login</a></li>
                    <li><a href="#register">Signup</a></li>
                </ul>
            </div>
        </div>
    </div>

    <div class="container">[Template content will be inserted here]</div>

    <footer>
    <ul class="inline text-center">
        <li>© 2013</li>
    </ul>
    </footer>
    <!--/.fluid-container-->

    <!-- Le javascript
================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <h:outputScript name="js/jquery-1.7.2.min.js" />
    <h:outputScript name="js/bootstrap.min.js" />
    <h:outputScript name="js/jquery.dataTables.min.js" />
    <h:outputScript name="js/bootstrap.js" />

</h:body>
</html>

但是,我得到:

<h:input> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: input

我真的很感谢你的回答!

4

2 回答 2

6

h:input标签在 JSF 中不存在。使用一些特定的输入标签,例如:h:inputHidden, h:inputText, h:inputSecret, h:inputTextarea

于 2013-04-11T13:11:16.083 回答
0

我有一个问题,你确定你的意思是 h:input 而不是 h:inputtext?

抱歉-> 编辑:您正在执行以下操作:

          <form class="navbar-form pull-left">
                <div class="input-append offset1">
                    <h:input class="span5" placeholder="put search terms here"
                        type="text" />
                    <button class="btn" type="submit">
                        <i class="icon-search"></i>
                    </button>
                </div>
            </form>

那是普通的html,如果你想使用JSF的魔力,你必须做这样的事情:

            <h:form>
                    <h:inputText value="#{hereIsYourManagedBean.field}" />
                    <h:commandButton action="#{hereIsYourManagedbean.action}">
                         DoJsfAction
                    </h:commandButton >

            </h:form>

JSF-Servlet 将捕获您的操作,呈现输入表单,将其放入您的 ManagedBean 字段中,调用 ManagedBean 的方法,最后根据您的方法创建响应。主要是由您的 faces-config.xml 配置的另一个 xhtml 站点

于 2013-04-11T13:10:24.573 回答