【发布时间】:2012-09-21 18:27:42
【问题描述】:
我有一个 Primefaces 图表,我想将它与 AJAX 选项卡一起使用:
<h:head>
</h:head>
<h:body>
<div id="test" style="width:850px; height:800px; position:absolute; background-color:transparent; ">
<h:form>
<h:panelGroup layout="block">
<h:selectOneListbox size="0" id="selectedMenu" value="#{dashboardController.selectedMenu}">
<f:selectItem itemLabel="first" itemValue="0" />
<f:selectItem itemLabel="second" itemValue="1" />
<f:selectItem itemLabel="third" itemValue="2" />
<f:ajax event="change" execute="@this" render="loadMenu" />
</h:selectOneListbox>
</h:panelGroup>
<h:panelGroup layout="block" id="loadMenu">
<h:panelGroup rendered="#{dashboardController.selectedMenu=='0'}">
MENU 0
</h:panelGroup>
<h:panelGroup rendered="#{dashboardController.selectedMenu=='1'}">
MENU 1
</h:panelGroup>
<h:panelGroup rendered="#{dashboardController.selectedMenu=='2'}">
MENU 2
</h:panelGroup>
</h:panelGroup>
</h:form>
</div>
</h:body>
@ManagedBean
@ViewScoped
public class DashboardController implements Serializable{
private String selectedMenu;
@PostConstruct
public void init() {
if (selectedMenu == null || selectedMenu.trim().isEmpty()) {
this.selectedMenu = "0";
}
}
public String getSelectedMenu() {
return selectedMenu;
}
public void setSelectedMenu(String selectedMenu) {
this.selectedMenu = selectedMenu;
}
}
我在图表中使用此代码:
<script type="text/javascript">
$.noConflict();
// Code that uses other library's $ can follow here.
</script>
..........
<p:lineChart id="logins" value="#{StatisticsController.weekActivity}" legendPosition="ne"
title="Weekly Logins" seriesColors="4D94FF, 1975FF, 005CE6, 0047B2" minY="0" maxY="200"/>
当我删除时
<script type="text/javascript">
$.noConflict();
// Code that uses other library's $ can follow here.
</script>
当 AJAX 选项卡工作时。 $.noConflict(); 代码似乎有冲突。我该如何解决这个问题?
【问题讨论】:
-
这并不能解决问题。
-
什么样的冲突?您是否在使用其他使用
$的库? -
客户端 jQuery 和服务器端组件之间没有冲突。
-
我使用使用 JQuery 的 Primefaces。我再次包括 JQuery。 $.noConflict();用于防止冲突。没有它,Primefaces 图表将无法正常工作。
-
如果该组件在您的文档中使用了 jQuery,为什么还要再次加载 jQuery?
标签: javascript jquery jsf jsf-2 primefaces