0
將按鈕集放入Primefaces時出現問題。 我看到一些其他帖子 How to use jQuery and jQuery plugins with PrimeFaces 與類似的問題,並沒有得到任何結果。Jquery和Primefaces存在的問題
繼承人的一個代碼示例:
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view locale="#{templateManager.userLocale}">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>#{msgs['report.title']}</title>
<h:outputStylesheet name="ssl-common.css" library="css"/>
<h:outputStylesheet name="final.css" library="css"/>
<link href="#{resource['img:favicon.ico']}" rel="icon"/>
<h:outputScript library="primefaces" name="jquery/jquery.js" />
</h:head>
<body id="reportList">
<ui:include src="../WEB-INF/header.xhtml" />
<section>
<h:form prependId="false">
<nav>
<div id="actionBar">
<div class="wraper">
<hgroup>
<h1>#{msgs['report.title']}</h1>
</hgroup>
<div id="subMenu" style="padding: 10px">
<script>
$(function() {
$("#radio").buttonset();
});
</script>
<div id="radio">
<input type="radio" id="radio1" name="radio" /><label for="radio1">Choice 1</label>
<input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Choice 2</label>
<input type="radio" id="radio3" name="radio" /><label for="radio3">Choice 3</label>
</div>
</div>
</div>
</div>
</nav>
(...)
<h:outputScript library="js" name="common.js"/>
<h:outputScript library="js" name="script.js"/>
<h:outputScript library="js" name="primefacesLocalePT-PT.js" />
<!--<h:outputScript library="js" name="jquery-ui-1.8.2.js" />-->
<script src="http://maps.google.com/maps/api/js?sensor=true&language=#{templateManager.userLocale}" type="text/javascript"/>
</body>
</f:view>
</html>
有了這個代碼,我收到錯誤:
類型錯誤:$(...)buttonset不是一個函數 [打破這個錯誤] (「#radio」)。buttonset();
有沒有人有類似的問題?
是的。但糾正我,如果我錯了,是不是primefaces有這個嵌入式功能? – Zebedeu 2013-03-15 15:07:15
@RuiBatalha是的,但你也手動包含jQuery.js。 Primefaces將自動包含所有必需的jQuery部件,但您必須在頁面上至少有一個Primefaces組件,在這裏不是這種情況。 – partlov 2013-03-15 15:29:01
@partlov抱歉,我刪除了使用primefaces的部分代碼:S 但是我覺得有些奇怪。在我的項目中在primefaces中搜索jar我沒有看到資源按鈕(META-INF.resources.primefaces ... )。 我感到困惑。 Primefaces不使用jQuery-ui按鈕? – Zebedeu 2013-03-15 15:32:07